Open jazeved0 opened 3 years ago
Thanks for reporting this.
This is a duplicate of #6353 as the underlying code is the same, but I will leave this open so other users can find the problem searching for either lint.
Fixing this would involve fixing/improving drop-tracking in rustc
when it comes to building the generator_interior_types
collection. drop-tracking is currently disabled by default though. So nothing much that could be done here on the Clippy side.
Has anything changed in the last year+ concerning drop tracking? @flip1995
I don't know. With a quick grep
though the Rust codebase, I couldn't find the drop_tracking
option anymore. So it might be enabled by default now. But I'm not sure.
Drop tracking was enabled by default in rust 1.74 ( https://github.com/rust-lang/rust/releases/tag/1.74.0 )
I tried this code:
I expected to see this happen: it should pass Clippy with no linting errors because the
MutexGuard
is explicitly dropped before the await point with a call tostd::mem::drop
.Instead, this happened: Clippy failed the lint check because of a violation of
clippy::await_holding_lock
:Running with
--verbose
does not provide any additional information.Additionally, of note, the following code does pass Clippy:
Meta
cargo clippy -V
: clippy 0.0.212 (7eac88a 2020-11-16)rustc -Vv
:Backtrace
``` $ RUST_BACKTRACE=1 cargo clippy Checking bug_report v0.1.0 (/home/jazev/dev/architus/logs/bug_report) error: this MutexGuard is held across an 'await' point. Consider using an async-aware Mutex type or ensuring the MutexGuard is dropped before calling await. --> src/lib.rs:8:9 | 8 | let mut set = lock.lock().unwrap(); | ^^^^^^^ | note: the lint level is defined here --> src/lib.rs:1:8 | 1 | #[deny(clippy::pedantic)] | ^^^^^^^^^^^^^^^^ = note: `#[deny(clippy::await_holding_lock)]` implied by `#[deny(clippy::pedantic)]` note: these are all the await points this lock is held through --> src/lib.rs:8:5 | 8 | / let mut set = lock.lock().unwrap(); 9 | | set.insert(0); 10 | | drop(set); 11 | | tokio::time::sleep(Duration::from_secs(1)).await; 12 | | } | |_^ = help: for further information visit https://rust-lang.github.io/rust- clippy/master/index.html#await_holding_lock error: aborting due to previous error error: could not compile `bug_report` To learn more, run the command again with --verbose. ```