decouple 'let_underscore' tests

This commit is contained in:
Mikhail Babenko 2020-01-28 12:28:11 +03:00 committed by Areredify
parent d1f8621711
commit 9b88a2b295
7 changed files with 53 additions and 48 deletions

View file

@ -6,7 +6,7 @@
A collection of lints to catch common mistakes and improve your [Rust](https://github.com/rust-lang/rust) code. 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: We have a bunch of lint categories to allow you to choose how much Clippy is supposed to ~~annoy~~ help you:

View file

@ -80,7 +80,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetUnderscore {
cx, cx,
LET_UNDERSCORE_LOCK, LET_UNDERSCORE_LOCK,
stmt.span, stmt.span,
"non-binding let on an a synchronization lock", "non-binding let on a synchronization lock",
"consider using an underscore-prefixed named binding" "consider using an underscore-prefixed named binding"
) )
} else { } else {

View file

@ -6,7 +6,7 @@ pub use lint::Lint;
pub use lint::LINT_LEVELS; pub use lint::LINT_LEVELS;
// begin lint list, do not remove this comment, its used in `update_lints` // begin lint list, do not remove this comment, its used in `update_lints`
pub const ALL_LINTS: [Lint; 350] = [ pub const ALL_LINTS: [Lint; 351] = [
Lint { Lint {
name: "absurd_extreme_comparisons", name: "absurd_extreme_comparisons",
group: "correctness", group: "correctness",

View file

@ -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();
}

View file

@ -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

View file

@ -88,11 +88,4 @@ fn main() {
let _ = a.map(|_| ()); let _ = a.map(|_| ());
let _ = a; let _ = a;
let m = std::sync::Mutex::new(());
let rw = std::sync::RwLock::new(());
let _ = m.lock();
let _ = rw.read();
let _ = rw.write();
} }

View file

@ -1,5 +1,5 @@
error: non-binding let on a result of a `#[must_use]` function 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(); LL | let _ = f();
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
@ -8,7 +8,7 @@ LL | let _ = f();
= help: consider explicitly using function result = help: consider explicitly using function result
error: non-binding let on an expression with `#[must_use]` type 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(); LL | let _ = g();
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
@ -16,7 +16,7 @@ LL | let _ = g();
= help: consider explicitly using expression value = help: consider explicitly using expression value
error: non-binding let on a result of a `#[must_use]` function 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); LL | let _ = l(0_u32);
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^
@ -24,7 +24,7 @@ LL | let _ = l(0_u32);
= help: consider explicitly using function result = help: consider explicitly using function result
error: non-binding let on a result of a `#[must_use]` function 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(); LL | let _ = s.f();
| ^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^
@ -32,7 +32,7 @@ LL | let _ = s.f();
= help: consider explicitly using function result = help: consider explicitly using function result
error: non-binding let on an expression with `#[must_use]` type 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(); LL | let _ = s.g();
| ^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^
@ -40,7 +40,7 @@ LL | let _ = s.g();
= help: consider explicitly using expression value = help: consider explicitly using expression value
error: non-binding let on a result of a `#[must_use]` function 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(); LL | let _ = S::h();
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^
@ -48,7 +48,7 @@ LL | let _ = S::h();
= help: consider explicitly using function result = help: consider explicitly using function result
error: non-binding let on an expression with `#[must_use]` type 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(); LL | let _ = S::p();
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^
@ -56,7 +56,7 @@ LL | let _ = S::p();
= help: consider explicitly using expression value = help: consider explicitly using expression value
error: non-binding let on a result of a `#[must_use]` function 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(); LL | let _ = S::a();
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^
@ -64,7 +64,7 @@ LL | let _ = S::a();
= help: consider explicitly using function result = help: consider explicitly using function result
error: non-binding let on an expression with `#[must_use]` type 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(()) }; LL | let _ = if true { Ok(()) } else { Err(()) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -72,7 +72,7 @@ LL | let _ = if true { Ok(()) } else { Err(()) };
= help: consider explicitly using expression value = help: consider explicitly using expression value
error: non-binding let on a result of a `#[must_use]` function 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(); LL | let _ = a.is_ok();
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
@ -80,7 +80,7 @@ LL | let _ = a.is_ok();
= help: consider explicitly using function result = help: consider explicitly using function result
error: non-binding let on an expression with `#[must_use]` type 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(|_| ()); LL | let _ = a.map(|_| ());
| ^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^
@ -88,37 +88,12 @@ LL | let _ = a.map(|_| ());
= help: consider explicitly using expression value = help: consider explicitly using expression value
error: non-binding let on an expression with `#[must_use]` type 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; LL | let _ = a;
| ^^^^^^^^^^ | ^^^^^^^^^^
| |
= help: consider explicitly using expression value = help: consider explicitly using expression value
error: non-binding let on an a synchronization lock error: aborting due to 12 previous errors
--> $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