kahing / catfs

Cache AnyThing filesystem written in Rust
Apache License 2.0
842 stars 54 forks source link

error: non-binding let on a synchronization lock #71

Closed tjni closed 11 months ago

tjni commented 1 year ago

Due to a new lint in rust 1.65 introduced by https://github.com/rust-lang/rust/pull/97739, there is a new compilation error:

error: non-binding let on a synchronization lock
   --> src/catfs/file.rs:570:13
    |
570 |         let _ = self.page_in_res.0.lock().unwrap();
    |             ^   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this binding will immediately drop the value assigned to it
    |             |
    |             this lock is not assigned to a binding and is immediately dropped
    |
    = note: `#[deny(let_underscore_lock)]` on by default
help: consider binding to an unused variable to avoid immediately dropping the value
    |
570 |         let _unused = self.page_in_res.0.lock().unwrap();
    |             ~~~~~~~
help: consider immediately dropping the value
    |
570 |         drop(self.page_in_res.0.lock().unwrap());
    |         ~~~~~                                  +

(Ignore the line numbers as they correspond to an older version, but I was able to verify it still occurs in v0.9.0 and the code triggering the error still exists.)

I was planning to fix this, but I can't figure out what the purpose of that line is. Is this mutex being used to gate access to more things than its internal data?

gaul commented 11 months ago

Resolved by 322b087a2df1d3f3d9560455cab7791312c9d5d0.