about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorYuki Okushi <yuki.okushi@huawei.com>2021-07-30 05:35:03 +0900
committerYuki Okushi <yuki.okushi@huawei.com>2021-07-31 06:12:42 +0900
commiteaff0fc25bfe6f831038953ff5bd8fa2372dba22 (patch)
tree4bb5b69920b362a1476cb59000607c123113c816 /src
parentf3f8e758f2b2abd84b76bcb4ec0b6ae263e1e7b9 (diff)
downloadrust-eaff0fc25bfe6f831038953ff5bd8fa2372dba22.tar.gz
rust-eaff0fc25bfe6f831038953ff5bd8fa2372dba22.zip
Add a hint that the expressions produce a value
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/lint/fn_must_use.stderr8
-rw-r--r--src/test/ui/lint/must-use-ops.stderr83
-rw-r--r--src/test/ui/lint/unused-borrows.stderr23
-rw-r--r--src/test/ui/unused/issue-85913.rs13
-rw-r--r--src/test/ui/unused/issue-85913.stderr15
5 files changed, 113 insertions, 29 deletions
diff --git a/src/test/ui/lint/fn_must_use.stderr b/src/test/ui/lint/fn_must_use.stderr
index d6b1cf3ae1f..75a22823329 100644
--- a/src/test/ui/lint/fn_must_use.stderr
+++ b/src/test/ui/lint/fn_must_use.stderr
@@ -47,13 +47,17 @@ warning: unused comparison that must be used
   --> $DIR/fn_must_use.rs:74:5
    |
 LL |     2 == 3;
-   |     ^^^^^^
+   |     ^^^^^^ help: use `let _ = ...` to ignore it: `let _ = 2 == 3`
+   |
+   = note: the comparison produces a value
 
 warning: unused comparison that must be used
   --> $DIR/fn_must_use.rs:75:5
    |
 LL |     m == n;
-   |     ^^^^^^
+   |     ^^^^^^ help: use `let _ = ...` to ignore it: `let _ = m == n`
+   |
+   = note: the comparison produces a value
 
 warning: 8 warnings emitted
 
diff --git a/src/test/ui/lint/must-use-ops.stderr b/src/test/ui/lint/must-use-ops.stderr
index 3fb80f7e798..73405d02a2e 100644
--- a/src/test/ui/lint/must-use-ops.stderr
+++ b/src/test/ui/lint/must-use-ops.stderr
@@ -2,133 +2,174 @@ warning: unused comparison that must be used
   --> $DIR/must-use-ops.rs:12:5
    |
 LL |     val == 1;
-   |     ^^^^^^^^
+   |     ^^^^^^^^ help: use `let _ = ...` to ignore it: `let _ = val == 1`
    |
 note: the lint level is defined here
   --> $DIR/must-use-ops.rs:5:9
    |
 LL | #![warn(unused_must_use)]
    |         ^^^^^^^^^^^^^^^
+   = note: the comparison produces a value
 
 warning: unused comparison that must be used
   --> $DIR/must-use-ops.rs:13:5
    |
 LL |     val < 1;
-   |     ^^^^^^^
+   |     ^^^^^^^ help: use `let _ = ...` to ignore it: `let _ = val < 1`
+   |
+   = note: the comparison produces a value
 
 warning: unused comparison that must be used
   --> $DIR/must-use-ops.rs:14:5
    |
 LL |     val <= 1;
-   |     ^^^^^^^^
+   |     ^^^^^^^^ help: use `let _ = ...` to ignore it: `let _ = val <= 1`
+   |
+   = note: the comparison produces a value
 
 warning: unused comparison that must be used
   --> $DIR/must-use-ops.rs:15:5
    |
 LL |     val != 1;
-   |     ^^^^^^^^
+   |     ^^^^^^^^ help: use `let _ = ...` to ignore it: `let _ = val != 1`
+   |
+   = note: the comparison produces a value
 
 warning: unused comparison that must be used
   --> $DIR/must-use-ops.rs:16:5
    |
 LL |     val >= 1;
-   |     ^^^^^^^^
+   |     ^^^^^^^^ help: use `let _ = ...` to ignore it: `let _ = val >= 1`
+   |
+   = note: the comparison produces a value
 
 warning: unused comparison that must be used
   --> $DIR/must-use-ops.rs:17:5
    |
 LL |     val > 1;
-   |     ^^^^^^^
+   |     ^^^^^^^ help: use `let _ = ...` to ignore it: `let _ = val > 1`
+   |
+   = note: the comparison produces a value
 
 warning: unused arithmetic operation that must be used
   --> $DIR/must-use-ops.rs:20:5
    |
 LL |     val + 2;
-   |     ^^^^^^^
+   |     ^^^^^^^ help: use `let _ = ...` to ignore it: `let _ = val + 2`
+   |
+   = note: the arithmetic operation produces a value
 
 warning: unused arithmetic operation that must be used
   --> $DIR/must-use-ops.rs:21:5
    |
 LL |     val - 2;
-   |     ^^^^^^^
+   |     ^^^^^^^ help: use `let _ = ...` to ignore it: `let _ = val - 2`
+   |
+   = note: the arithmetic operation produces a value
 
 warning: unused arithmetic operation that must be used
   --> $DIR/must-use-ops.rs:22:5
    |
 LL |     val / 2;
-   |     ^^^^^^^
+   |     ^^^^^^^ help: use `let _ = ...` to ignore it: `let _ = val / 2`
+   |
+   = note: the arithmetic operation produces a value
 
 warning: unused arithmetic operation that must be used
   --> $DIR/must-use-ops.rs:23:5
    |
 LL |     val * 2;
-   |     ^^^^^^^
+   |     ^^^^^^^ help: use `let _ = ...` to ignore it: `let _ = val * 2`
+   |
+   = note: the arithmetic operation produces a value
 
 warning: unused arithmetic operation that must be used
   --> $DIR/must-use-ops.rs:24:5
    |
 LL |     val % 2;
-   |     ^^^^^^^
+   |     ^^^^^^^ help: use `let _ = ...` to ignore it: `let _ = val % 2`
+   |
+   = note: the arithmetic operation produces a value
 
 warning: unused logical operation that must be used
   --> $DIR/must-use-ops.rs:27:5
    |
 LL |     true && true;
-   |     ^^^^^^^^^^^^
+   |     ^^^^^^^^^^^^ help: use `let _ = ...` to ignore it: `let _ = true && true`
+   |
+   = note: the logical operation produces a value
 
 warning: unused logical operation that must be used
   --> $DIR/must-use-ops.rs:28:5
    |
 LL |     false || true;
-   |     ^^^^^^^^^^^^^
+   |     ^^^^^^^^^^^^^ help: use `let _ = ...` to ignore it: `let _ = false || true`
+   |
+   = note: the logical operation produces a value
 
 warning: unused bitwise operation that must be used
   --> $DIR/must-use-ops.rs:31:5
    |
 LL |     5 ^ val;
-   |     ^^^^^^^
+   |     ^^^^^^^ help: use `let _ = ...` to ignore it: `let _ = 5 ^ val`
+   |
+   = note: the bitwise operation produces a value
 
 warning: unused bitwise operation that must be used
   --> $DIR/must-use-ops.rs:32:5
    |
 LL |     5 & val;
-   |     ^^^^^^^
+   |     ^^^^^^^ help: use `let _ = ...` to ignore it: `let _ = 5 & val`
+   |
+   = note: the bitwise operation produces a value
 
 warning: unused bitwise operation that must be used
   --> $DIR/must-use-ops.rs:33:5
    |
 LL |     5 | val;
-   |     ^^^^^^^
+   |     ^^^^^^^ help: use `let _ = ...` to ignore it: `let _ = 5 | val`
+   |
+   = note: the bitwise operation produces a value
 
 warning: unused bitwise operation that must be used
   --> $DIR/must-use-ops.rs:34:5
    |
 LL |     5 << val;
-   |     ^^^^^^^^
+   |     ^^^^^^^^ help: use `let _ = ...` to ignore it: `let _ = 5 << val`
+   |
+   = note: the bitwise operation produces a value
 
 warning: unused bitwise operation that must be used
   --> $DIR/must-use-ops.rs:35:5
    |
 LL |     5 >> val;
-   |     ^^^^^^^^
+   |     ^^^^^^^^ help: use `let _ = ...` to ignore it: `let _ = 5 >> val`
+   |
+   = note: the bitwise operation produces a value
 
 warning: unused unary operation that must be used
   --> $DIR/must-use-ops.rs:38:5
    |
 LL |     !val;
-   |     ^^^^
+   |     ^^^^ help: use `let _ = ...` to ignore it: `let _ = !val`
+   |
+   = note: the unary operation produces a value
 
 warning: unused unary operation that must be used
   --> $DIR/must-use-ops.rs:39:5
    |
 LL |     -val;
-   |     ^^^^
+   |     ^^^^ help: use `let _ = ...` to ignore it: `let _ = -val`
+   |
+   = note: the unary operation produces a value
 
 warning: unused unary operation that must be used
   --> $DIR/must-use-ops.rs:40:5
    |
 LL |     *val_pointer;
-   |     ^^^^^^^^^^^^
+   |     ^^^^^^^^^^^^ help: use `let _ = ...` to ignore it: `let _ = *val_pointer`
+   |
+   = note: the unary operation produces a value
 
 warning: 21 warnings emitted
 
diff --git a/src/test/ui/lint/unused-borrows.stderr b/src/test/ui/lint/unused-borrows.stderr
index 24899fe992b..459381b642c 100644
--- a/src/test/ui/lint/unused-borrows.stderr
+++ b/src/test/ui/lint/unused-borrows.stderr
@@ -2,43 +2,54 @@ error: unused borrow that must be used
   --> $DIR/unused-borrows.rs:6:5
    |
 LL |     &42;
-   |     ^^^
+   |     ^^^ help: use `let _ = ...` to ignore it: `let _ = &42`
    |
 note: the lint level is defined here
   --> $DIR/unused-borrows.rs:1:9
    |
 LL | #![deny(unused_must_use)]
    |         ^^^^^^^^^^^^^^^
+   = note: the borrow produces a value
 
 error: unused borrow that must be used
   --> $DIR/unused-borrows.rs:9:5
    |
 LL |     &mut foo(42);
-   |     ^^^^^^^^^^^^
+   |     ^^^^^^^^^^^^ help: use `let _ = ...` to ignore it: `let _ = &mut foo(42)`
+   |
+   = note: the borrow produces a value
 
 error: unused borrow that must be used
   --> $DIR/unused-borrows.rs:12:5
    |
 LL |     &&42;
-   |     ^^^^
+   |     ^^^^ help: use `let _ = ...` to ignore it: `let _ = &&42`
+   |
+   = note: the borrow produces a value
 
 error: unused borrow that must be used
   --> $DIR/unused-borrows.rs:15:5
    |
 LL |     &&mut 42;
-   |     ^^^^^^^^
+   |     ^^^^^^^^ help: use `let _ = ...` to ignore it: `let _ = &&mut 42`
+   |
+   = note: the borrow produces a value
 
 error: unused borrow that must be used
   --> $DIR/unused-borrows.rs:18:5
    |
 LL |     &mut &42;
-   |     ^^^^^^^^
+   |     ^^^^^^^^ help: use `let _ = ...` to ignore it: `let _ = &mut &42`
+   |
+   = note: the borrow produces a value
 
 error: unused borrow that must be used
   --> $DIR/unused-borrows.rs:23:5
    |
 LL |     && foo(42);
-   |     ^^^^^^^^^^
+   |     ^^^^^^^^^^ help: use `let _ = ...` to ignore it: `let _ = && foo(42)`
+   |
+   = note: the borrow produces a value
 
 error: aborting due to 6 previous errors
 
diff --git a/src/test/ui/unused/issue-85913.rs b/src/test/ui/unused/issue-85913.rs
new file mode 100644
index 00000000000..7f3817b6ef1
--- /dev/null
+++ b/src/test/ui/unused/issue-85913.rs
@@ -0,0 +1,13 @@
+#![deny(unused_must_use)]
+
+pub fn fun() -> i32 {
+    function() && return 1;
+    //~^ ERROR: unused logical operation that must be used
+    return 0;
+}
+
+fn function() -> bool {
+    true
+}
+
+fn main() {}
diff --git a/src/test/ui/unused/issue-85913.stderr b/src/test/ui/unused/issue-85913.stderr
new file mode 100644
index 00000000000..d5d99f0f7d3
--- /dev/null
+++ b/src/test/ui/unused/issue-85913.stderr
@@ -0,0 +1,15 @@
+error: unused logical operation that must be used
+  --> $DIR/issue-85913.rs:4:5
+   |
+LL |     function() && return 1;
+   |     ^^^^^^^^^^^^^^^^^^^^^^ help: use `let _ = ...` to ignore it: `let _ = function() && return 1`
+   |
+note: the lint level is defined here
+  --> $DIR/issue-85913.rs:1:9
+   |
+LL | #![deny(unused_must_use)]
+   |         ^^^^^^^^^^^^^^^
+   = note: the logical operation produces a value
+
+error: aborting due to previous error
+