diff --git a/README.md b/README.md index 0cb14eda6..b68eb3ed7 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ A collection of lints to catch common mistakes and improve your [Rust](https://github.com/rust-lang/rust) code. -[There are 350 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html) +[There are 351 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html) We have a bunch of lint categories to allow you to choose how much Clippy is supposed to ~~annoy~~ help you: diff --git a/clippy_lints/src/let_underscore.rs b/clippy_lints/src/let_underscore.rs index 4d746596c..a43674316 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/src/lintlist/mod.rs b/src/lintlist/mod.rs index 1f7d450ab..0c5b8146b 100644 --- a/src/lintlist/mod.rs +++ b/src/lintlist/mod.rs @@ -6,7 +6,7 @@ pub use lint::Lint; pub use lint::LINT_LEVELS; // begin lint list, do not remove this comment, it’s used in `update_lints` -pub const ALL_LINTS: [Lint; 350] = [ +pub const ALL_LINTS: [Lint; 351] = [ Lint { name: "absurd_extreme_comparisons", group: "correctness", diff --git a/tests/ui/let_underscore_lock.rs b/tests/ui/let_underscore_lock.rs new file mode 100644 index 000000000..f4a33c360 --- /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 000000000..bd297f602 --- /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 cfe207251..7f481542f 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 bcd560fe4..447f2419e 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