mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 13:13:34 +00:00
decouple 'let_underscore' tests
This commit is contained in:
parent
d1f8621711
commit
9b88a2b295
7 changed files with 53 additions and 48 deletions
|
@ -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:
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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",
|
||||
|
|
10
tests/ui/let_underscore_lock.rs
Normal file
10
tests/ui/let_underscore_lock.rs
Normal 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();
|
||||
}
|
27
tests/ui/let_underscore_lock.stderr
Normal file
27
tests/ui/let_underscore_lock.stderr
Normal 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
|
||||
|
|
@ -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();
|
||||
}
|
|
@ -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
|
||||
|
Loading…
Reference in a new issue