Skip to content

Commit

Permalink
decouple 'let_underscore' tests
Browse files Browse the repository at this point in the history
  • Loading branch information
basil-cow committed Jan 29, 2020
1 parent 7b1e678 commit 85a46b3
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 46 deletions.
2 changes: 1 addition & 1 deletion clippy_lints/src/let_underscore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetUnderscore {
cx,
LET_UNDERSCORE_LOCK,
stmt.span,
"non-binding let on an a synchronization lock",
"non-binding let on a synchronization lock",
"consider using an underscore-prefixed named binding"
)
} else {
Expand Down
10 changes: 10 additions & 0 deletions tests/ui/let_underscore_lock.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#![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();
}
27 changes: 27 additions & 0 deletions tests/ui/let_underscore_lock.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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

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

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

error: aborting due to 3 previous errors

Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,4 @@ fn main() {
let _ = a.map(|_| ());

let _ = a;

let m = std::sync::Mutex::new(());
let rw = std::sync::RwLock::new(());

let _ = m.lock();
let _ = rw.read();
let _ = rw.write();
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: non-binding let on a result of a `#[must_use]` function
--> $DIR/let_underscore.rs:66:5
--> $DIR/let_underscore_must_use.rs:66:5
|
LL | let _ = f();
| ^^^^^^^^^^^^
Expand All @@ -8,117 +8,92 @@ LL | let _ = f();
= help: consider explicitly using function result

error: non-binding let on an expression with `#[must_use]` type
--> $DIR/let_underscore.rs:67:5
--> $DIR/let_underscore_must_use.rs:67:5
|
LL | let _ = g();
| ^^^^^^^^^^^^
|
= help: consider explicitly using expression value

error: non-binding let on a result of a `#[must_use]` function
--> $DIR/let_underscore.rs:69:5
--> $DIR/let_underscore_must_use.rs:69:5
|
LL | let _ = l(0_u32);
| ^^^^^^^^^^^^^^^^^
|
= help: consider explicitly using function result

error: non-binding let on a result of a `#[must_use]` function
--> $DIR/let_underscore.rs:73:5
--> $DIR/let_underscore_must_use.rs:73:5
|
LL | let _ = s.f();
| ^^^^^^^^^^^^^^
|
= help: consider explicitly using function result

error: non-binding let on an expression with `#[must_use]` type
--> $DIR/let_underscore.rs:74:5
--> $DIR/let_underscore_must_use.rs:74:5
|
LL | let _ = s.g();
| ^^^^^^^^^^^^^^
|
= help: consider explicitly using expression value

error: non-binding let on a result of a `#[must_use]` function
--> $DIR/let_underscore.rs:77:5
--> $DIR/let_underscore_must_use.rs:77:5
|
LL | let _ = S::h();
| ^^^^^^^^^^^^^^^
|
= help: consider explicitly using function result

error: non-binding let on an expression with `#[must_use]` type
--> $DIR/let_underscore.rs:78:5
--> $DIR/let_underscore_must_use.rs:78:5
|
LL | let _ = S::p();
| ^^^^^^^^^^^^^^^
|
= help: consider explicitly using expression value

error: non-binding let on a result of a `#[must_use]` function
--> $DIR/let_underscore.rs:80:5
--> $DIR/let_underscore_must_use.rs:80:5
|
LL | let _ = S::a();
| ^^^^^^^^^^^^^^^
|
= help: consider explicitly using function result

error: non-binding let on an expression with `#[must_use]` type
--> $DIR/let_underscore.rs:82:5
--> $DIR/let_underscore_must_use.rs:82:5
|
LL | let _ = if true { Ok(()) } else { Err(()) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: consider explicitly using expression value

error: non-binding let on a result of a `#[must_use]` function
--> $DIR/let_underscore.rs:86:5
--> $DIR/let_underscore_must_use.rs:86:5
|
LL | let _ = a.is_ok();
| ^^^^^^^^^^^^^^^^^^
|
= help: consider explicitly using function result

error: non-binding let on an expression with `#[must_use]` type
--> $DIR/let_underscore.rs:88:5
--> $DIR/let_underscore_must_use.rs:88:5
|
LL | let _ = a.map(|_| ());
| ^^^^^^^^^^^^^^^^^^^^^^
|
= help: consider explicitly using expression value

error: non-binding let on an expression with `#[must_use]` type
--> $DIR/let_underscore.rs:90:5
--> $DIR/let_underscore_must_use.rs:90:5
|
LL | let _ = a;
| ^^^^^^^^^^
|
= help: consider explicitly using expression value

error: non-binding let on an a synchronization lock
--> $DIR/let_underscore.rs:95:5
|
LL | let _ = m.lock();
| ^^^^^^^^^^^^^^^^^
|
= note: `#[deny(clippy::let_underscore_lock)]` on by default
= help: consider using an underscore-prefixed named binding

error: non-binding let on an a synchronization lock
--> $DIR/let_underscore.rs:96:5
|
LL | let _ = rw.read();
| ^^^^^^^^^^^^^^^^^^
|
= help: consider using an underscore-prefixed named binding

error: non-binding let on an a synchronization lock
--> $DIR/let_underscore.rs:97:5
|
LL | let _ = rw.write();
| ^^^^^^^^^^^^^^^^^^^
|
= help: consider using an underscore-prefixed named binding

error: aborting due to 15 previous errors
error: aborting due to 12 previous errors

0 comments on commit 85a46b3

Please sign in to comment.