]> git.lizzy.rs Git - rust.git/commitdiff
decouple 'let_underscore' tests
authorMikhail Babenko <misha-babenko@yandex.ru>
Tue, 28 Jan 2020 09:28:11 +0000 (12:28 +0300)
committerAreredify <misha-babenko@yandex.ru>
Thu, 30 Jan 2020 13:51:23 +0000 (16:51 +0300)
README.md
clippy_lints/src/let_underscore.rs
src/lintlist/mod.rs
tests/ui/let_underscore.rs [deleted file]
tests/ui/let_underscore.stderr [deleted file]
tests/ui/let_underscore_lock.rs [new file with mode: 0644]
tests/ui/let_underscore_lock.stderr [new file with mode: 0644]
tests/ui/let_underscore_must_use.rs [new file with mode: 0644]
tests/ui/let_underscore_must_use.stderr [new file with mode: 0644]

index 0cb14eda6a8812f8aea8e7b6cd4734db1a363ce3..b68eb3ed7fab8beaf433b2e369efcfebd789f004 100644 (file)
--- 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.
 
 
 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:
 
index 4d746596c377cdf389c38fb30b1658906d9ce638..a43674316a1e5cedd5d656036f25e65fcbcf699b 100644 (file)
@@ -80,7 +80,7 @@ fn check_stmt(&mut self, cx: &LateContext<'_, '_>, stmt: &Stmt<'_>) {
                             cx,
                             LET_UNDERSCORE_LOCK,
                             stmt.span,
                             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 {
                             "consider using an underscore-prefixed named binding"
                         )
                     } else {
index 1f7d450ab66eb831b7dc261e19828cbd2d2514d7..0c5b8146b136114e453297f82fbde96a75ee76b1 100644 (file)
@@ -6,7 +6,7 @@
 pub use lint::LINT_LEVELS;
 
 // begin lint list, do not remove this comment, it’s used in `update_lints`
 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",
     Lint {
         name: "absurd_extreme_comparisons",
         group: "correctness",
diff --git a/tests/ui/let_underscore.rs b/tests/ui/let_underscore.rs
deleted file mode 100644 (file)
index cfe2072..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-#![warn(clippy::let_underscore_must_use)]
-
-// Debug implementations can fire this lint,
-// so we shouldn't lint external macros
-#[derive(Debug)]
-struct Foo {
-    field: i32,
-}
-
-#[must_use]
-fn f() -> u32 {
-    0
-}
-
-fn g() -> Result<u32, u32> {
-    Ok(0)
-}
-
-#[must_use]
-fn l<T>(x: T) -> T {
-    x
-}
-
-fn h() -> u32 {
-    0
-}
-
-struct S {}
-
-impl S {
-    #[must_use]
-    pub fn f(&self) -> u32 {
-        0
-    }
-
-    pub fn g(&self) -> Result<u32, u32> {
-        Ok(0)
-    }
-
-    fn k(&self) -> u32 {
-        0
-    }
-
-    #[must_use]
-    fn h() -> u32 {
-        0
-    }
-
-    fn p() -> Result<u32, u32> {
-        Ok(0)
-    }
-}
-
-trait Trait {
-    #[must_use]
-    fn a() -> u32;
-}
-
-impl Trait for S {
-    fn a() -> u32 {
-        0
-    }
-}
-
-fn main() {
-    let _ = f();
-    let _ = g();
-    let _ = h();
-    let _ = l(0_u32);
-
-    let s = S {};
-
-    let _ = s.f();
-    let _ = s.g();
-    let _ = s.k();
-
-    let _ = S::h();
-    let _ = S::p();
-
-    let _ = S::a();
-
-    let _ = if true { Ok(()) } else { Err(()) };
-
-    let a = Result::<(), ()>::Ok(());
-
-    let _ = a.is_ok();
-
-    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.stderr
deleted file mode 100644 (file)
index bcd560f..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-error: non-binding let on a result of a `#[must_use]` function
-  --> $DIR/let_underscore.rs:66:5
-   |
-LL |     let _ = f();
-   |     ^^^^^^^^^^^^
-   |
-   = note: `-D clippy::let-underscore-must-use` implied by `-D warnings`
-   = help: consider explicitly using function result
-
-error: non-binding let on an expression with `#[must_use]` type
-  --> $DIR/let_underscore.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
-   |
-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
-   |
-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
-   |
-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
-   |
-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
-   |
-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
-   |
-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
-   |
-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
-   |
-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
-   |
-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
-   |
-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
-
diff --git a/tests/ui/let_underscore_lock.rs b/tests/ui/let_underscore_lock.rs
new file mode 100644 (file)
index 0000000..f4a33c3
--- /dev/null
@@ -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 (file)
index 0000000..bd297f6
--- /dev/null
@@ -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_must_use.rs b/tests/ui/let_underscore_must_use.rs
new file mode 100644 (file)
index 0000000..7f48154
--- /dev/null
@@ -0,0 +1,91 @@
+#![warn(clippy::let_underscore_must_use)]
+
+// Debug implementations can fire this lint,
+// so we shouldn't lint external macros
+#[derive(Debug)]
+struct Foo {
+    field: i32,
+}
+
+#[must_use]
+fn f() -> u32 {
+    0
+}
+
+fn g() -> Result<u32, u32> {
+    Ok(0)
+}
+
+#[must_use]
+fn l<T>(x: T) -> T {
+    x
+}
+
+fn h() -> u32 {
+    0
+}
+
+struct S {}
+
+impl S {
+    #[must_use]
+    pub fn f(&self) -> u32 {
+        0
+    }
+
+    pub fn g(&self) -> Result<u32, u32> {
+        Ok(0)
+    }
+
+    fn k(&self) -> u32 {
+        0
+    }
+
+    #[must_use]
+    fn h() -> u32 {
+        0
+    }
+
+    fn p() -> Result<u32, u32> {
+        Ok(0)
+    }
+}
+
+trait Trait {
+    #[must_use]
+    fn a() -> u32;
+}
+
+impl Trait for S {
+    fn a() -> u32 {
+        0
+    }
+}
+
+fn main() {
+    let _ = f();
+    let _ = g();
+    let _ = h();
+    let _ = l(0_u32);
+
+    let s = S {};
+
+    let _ = s.f();
+    let _ = s.g();
+    let _ = s.k();
+
+    let _ = S::h();
+    let _ = S::p();
+
+    let _ = S::a();
+
+    let _ = if true { Ok(()) } else { Err(()) };
+
+    let a = Result::<(), ()>::Ok(());
+
+    let _ = a.is_ok();
+
+    let _ = a.map(|_| ());
+
+    let _ = a;
+}
diff --git a/tests/ui/let_underscore_must_use.stderr b/tests/ui/let_underscore_must_use.stderr
new file mode 100644 (file)
index 0000000..447f241
--- /dev/null
@@ -0,0 +1,99 @@
+error: non-binding let on a result of a `#[must_use]` function
+  --> $DIR/let_underscore_must_use.rs:66:5
+   |
+LL |     let _ = f();
+   |     ^^^^^^^^^^^^
+   |
+   = note: `-D clippy::let-underscore-must-use` implied by `-D warnings`
+   = help: consider explicitly using function result
+
+error: non-binding let on an expression with `#[must_use]` type
+  --> $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_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_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_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_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_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_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_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_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_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_must_use.rs:90:5
+   |
+LL |     let _ = a;
+   |     ^^^^^^^^^^
+   |
+   = help: consider explicitly using expression value
+
+error: aborting due to 12 previous errors
+