Repository navigation
Different behavior of the let_underscore_lock lint in rustc compared to clippy #102771
Copy link
Copy link
Closed
Closed
Copy link
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Activity
Fixed by #119710:
fn main() { let _ = parking_lot::Mutex::new(()).lock(); let _ = std::sync::Mutex::new(()).lock(); }
results in
result
error: non-binding `let` on a synchronization lock --> src/main.rs:2:5 | 2 | let _ = parking_lot::Mutex::new(()).lock(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider using an underscore-prefixed named binding or dropping explicitly with `std::mem::drop` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_underscore_lock = note: `#[deny(clippy::let_underscore_lock)]` on by default error: non-binding let on a synchronization lock --> src/main.rs:3:9 | 3 | let _ = std::sync::Mutex::new(()).lock(); | ^ 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 | 3 | let _unused = std::sync::Mutex::new(()).lock(); | ~~~~~~~ help: consider immediately dropping the value | 3 | drop(std::sync::Mutex::new(()).lock()); | ~~~~~ + error: could not compile `playground` (bin "playground") due to 2 previous errorsTested in tests/ui/lint/let_underscore/let_underscore_lock.rs
- addedA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.and removed
on Apr 17, 2024 Closing as fixed.
- addedA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.and removedA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.
on Dec 21, 2024
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
I tried this code with the new rustc lint:
Clippy warns here, but rustc doesn't. This might be intentional, but I think this could be a source of mistakes...
The rustc lint is triggered, as soon as I use
.lock().unwrap()Meta
rustc --version --verbose: