-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have
Description
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:
pub(crate) static SOCKETS: SyncLazy<Mutex<HashSet<Socket>>> =
SyncLazy::new(|| Mutex::new(HashSet::new()));
fn bind(sockfd: c_int, addr: *const sockaddr, addrlen: socklen_t) -> c_int {
debug!("bind called sockfd: {:?}", sockfd);
let mut socket = {
let mut sockets = SOCKETS.lock().unwrap();
match sockets.take(&sockfd) {
Some(socket) if !matches!(socket.state, SocketState::Initialized) => {
error!("socket is in invalid state for bind {:?}", socket.state);
return libc::EINVAL;
}
Some(socket) => socket,
None => {
debug!("bind: no socket found for fd: {}", &sockfd);
return unsafe { libc::bind(sockfd, addr, addrlen) };
}
}
};
....
I saw this happen:
--> mirrord-layer/src/sockets.rs:168:15
|
168 | match sockets.take(&sockfd) {
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D clippy::significant-drop-in-scrutinee` implied by `-D warnings`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#significant_drop_in_scrutinee
Version
rustc 1.63.0-nightly (50b00252a 2022-06-06) (from rustc 1.63.0-nightly (50b00252a 2022-06-06))
Additional Labels
No response
xudong963
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have
Activity
SpriteOvO commentedon Jun 10, 2022
Same problem:
Warning:
Version:
Kixiron commentedon Jun 11, 2022
The false positives also appear in for loops
Playground
Note that this doesn't appear with just
HashSet::drain()
, as shown herealice-i-cecile commentedon Jul 1, 2022
We're hitting a false positive here too: bevyengine/bevy#5160.
SpriteOvO commentedon Aug 14, 2022
For me, this false positive no longer occurs in the latest version.
significant_drop_in_scrutinee
: Trigger lint only if lifetime allows early significant drop #12740significant_drop_in_scrutinee
: Fix false positives due to false drops of place expressions #12764Auto merge of #12764 - lrh2000:ignore-place, r=blyxyas