diff --git a/clippy_lints/src/let_underscore.rs b/clippy_lints/src/let_underscore.rs index 4d746596c377..a43674316a1e 100644 --- a/clippy_lints/src/let_underscore.rs +++ b/clippy_lints/src/let_underscore.rs @@ -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 { diff --git a/tests/ui/let_underscore_lock.rs b/tests/ui/let_underscore_lock.rs new file mode 100644 index 000000000000..f4a33c360660 --- /dev/null +++ b/tests/ui/let_underscore_lock.rs @@ -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(); +} diff --git a/tests/ui/let_underscore_lock.stderr b/tests/ui/let_underscore_lock.stderr new file mode 100644 index 000000000000..bd297f6020cc --- /dev/null +++ b/tests/ui/let_underscore_lock.stderr @@ -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 + diff --git a/tests/ui/let_underscore.rs b/tests/ui/let_underscore_must_use.rs similarity index 88% rename from tests/ui/let_underscore.rs rename to tests/ui/let_underscore_must_use.rs index cfe207251f47..7f481542fa73 100644 --- a/tests/ui/let_underscore.rs +++ b/tests/ui/let_underscore_must_use.rs @@ -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(); } diff --git a/tests/ui/let_underscore.stderr b/tests/ui/let_underscore_must_use.stderr similarity index 66% rename from tests/ui/let_underscore.stderr rename to tests/ui/let_underscore_must_use.stderr index bcd560fe493f..447f2419e3bd 100644 --- a/tests/ui/let_underscore.stderr +++ b/tests/ui/let_underscore_must_use.stderr @@ -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(); | ^^^^^^^^^^^^ @@ -8,7 +8,7 @@ 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(); | ^^^^^^^^^^^^ @@ -16,7 +16,7 @@ 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); | ^^^^^^^^^^^^^^^^^ @@ -24,7 +24,7 @@ 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(); | ^^^^^^^^^^^^^^ @@ -32,7 +32,7 @@ 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(); | ^^^^^^^^^^^^^^ @@ -40,7 +40,7 @@ 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(); | ^^^^^^^^^^^^^^^ @@ -48,7 +48,7 @@ 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(); | ^^^^^^^^^^^^^^^ @@ -56,7 +56,7 @@ 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(); | ^^^^^^^^^^^^^^^ @@ -64,7 +64,7 @@ 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(()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -72,7 +72,7 @@ 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(); | ^^^^^^^^^^^^^^^^^^ @@ -80,7 +80,7 @@ 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(|_| ()); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -88,37 +88,12 @@ 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