forked from rust-lang/rust-clippy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#5101 - Areredify:let_underscore_lock, r=flip1995
add `let_underscore_lock` lint closes rust-lang#1574 changelog: add `let_underscore_lock` lint I am not entirely sure about my docs/messages wording here, improvements are welcome
- Loading branch information
Showing
10 changed files
with
139 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#![warn(clippy::let_underscore_lock)] | ||
|
||
fn main() { | ||
let m = std::sync::Mutex::new(()); | ||
let rw = std::sync::RwLock::new(()); | ||
|
||
let _ = m.lock(); | ||
let _ = rw.read(); | ||
let _ = rw.write(); | ||
let _ = m.try_lock(); | ||
let _ = rw.try_read(); | ||
let _ = rw.try_write(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
error: non-binding let on a synchronization lock | ||
--> $DIR/let_underscore_lock.rs:7:5 | ||
| | ||
LL | let _ = m.lock(); | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `-D clippy::let-underscore-lock` implied by `-D warnings` | ||
= help: consider using an underscore-prefixed named binding or dropping explicitly with `std::mem::drop` | ||
|
||
error: non-binding let on a synchronization lock | ||
--> $DIR/let_underscore_lock.rs:8:5 | ||
| | ||
LL | let _ = rw.read(); | ||
| ^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: consider using an underscore-prefixed named binding or dropping explicitly with `std::mem::drop` | ||
|
||
error: non-binding let on a synchronization lock | ||
--> $DIR/let_underscore_lock.rs:9:5 | ||
| | ||
LL | let _ = rw.write(); | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: consider using an underscore-prefixed named binding or dropping explicitly with `std::mem::drop` | ||
|
||
error: non-binding let on a synchronization lock | ||
--> $DIR/let_underscore_lock.rs:10:5 | ||
| | ||
LL | let _ = m.try_lock(); | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: consider using an underscore-prefixed named binding or dropping explicitly with `std::mem::drop` | ||
|
||
error: non-binding let on a synchronization lock | ||
--> $DIR/let_underscore_lock.rs:11:5 | ||
| | ||
LL | let _ = rw.try_read(); | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: consider using an underscore-prefixed named binding or dropping explicitly with `std::mem::drop` | ||
|
||
error: non-binding let on a synchronization lock | ||
--> $DIR/let_underscore_lock.rs:12:5 | ||
| | ||
LL | let _ = rw.try_write(); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: consider using an underscore-prefixed named binding or dropping explicitly with `std::mem::drop` | ||
|
||
error: aborting due to 6 previous errors | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters