-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
significant-drop-in-scrutinee when false positive #8963
Labels
C-bug
Category: Clippy is not doing the correct thing
I-false-positive
Issue: The lint was triggered on code it shouldn't have
Comments
aviramha
added
C-bug
Category: Clippy is not doing the correct thing
I-false-positive
Issue: The lint was triggered on code it shouldn't have
labels
Jun 7, 2022
Same problem: pub(crate) fn default_thread_pool() -> Arc<ThreadPool> {
static POOL_WEAK: Lazy<Mutex<Weak<ThreadPool>>> = Lazy::new(|| Mutex::new(Weak::new()));
let mut pool_weak = POOL_WEAK.lock_expect(); // `lock_expect` is a wrapper of `lock().expect("xxx")`
match pool_weak.upgrade() {
Some(pool) => pool,
None => {
let pool = Arc::new(ThreadPool::builder().build().unwrap());
*pool_weak = Arc::downgrade(&pool);
pool
}
}
} Warning:
Version:
|
The false positives also appear in for loops use std::{sync::Mutex, collections::HashSet};
fn main() {
let nodes: Mutex<HashSet<u8>> = Mutex::new(HashSet::new());
let mut nodes = nodes.lock().unwrap();
for node in nodes.drain() {
println!("{node}");
}
} warning: temporary with significant drop in for loop
--> src/main.rs:7:17
|
7 | for node in nodes.drain() {
| ^^^^^^^^^^^^^
|
= note: `#[warn(clippy::significant_drop_in_scrutinee)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#significant_drop_in_scrutinee
warning: `playground` (bin "playground") generated 1 warning Note that this doesn't appear with just use std::collections::HashSet;
fn main() {
let mut nodes = HashSet::<u8>::new();
for node in nodes.drain() {
println!("{node}");
}
}
|
We're hitting a false positive here too: bevyengine/bevy#5160. |
For me, this false positive no longer occurs in the latest version.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
C-bug
Category: Clippy is not doing the correct thing
I-false-positive
Issue: The lint was triggered on code it shouldn't have
Summary
Last version of clippy seems to have false positive on the lint
happens in our CI
https://github.com/metalbear-co/mirrord/runs/6770432194?check_suite_focus=true
Lint Name
significant-drop-in-scrutinee
Reproducer
I tried this code:
I saw this happen:
Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: