Skip to content

Commit

Permalink
Reword unused variable warning
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksator committed Mar 23, 2020
1 parent 8ff7850 commit b35c302
Show file tree
Hide file tree
Showing 22 changed files with 69 additions and 69 deletions.
4 changes: 2 additions & 2 deletions src/doc/rustc/src/json.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ Diagnostics have the following format:
"rendered": null
},
{
"message": "consider prefixing with an underscore",
"message": "if this is intentional, prefix it with an underscore",
"code": null,
"level": "help",
"spans": [
Expand Down Expand Up @@ -201,7 +201,7 @@ Diagnostics have the following format:
/* Optional string of the rendered version of the diagnostic as displayed
by rustc. Note that this may be influenced by the `--json` flag.
*/
"rendered": "warning: unused variable: `x`\n --> lib.rs:2:9\n |\n2 | let x = 123;\n | ^ help: consider prefixing with an underscore: `_x`\n |\n = note: `#[warn(unused_variables)]` on by default\n\n"
"rendered": "warning: unused variable: `x`\n --> lib.rs:2:9\n |\n2 | let x = 123;\n | ^ help: if this is intentional, prefix it with an underscore: `_x`\n |\n = note: `#[warn(unused_variables)]` on by default\n\n"
}
```

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_passes/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1565,7 +1565,7 @@ impl<'tcx> Liveness<'_, 'tcx> {
}
} else {
err.multipart_suggestion(
"consider prefixing with an underscore",
"if this is intentional, prefix it with an underscore",
spans.iter().map(|span| (*span, format!("_{}", name))).collect(),
Applicability::MachineApplicable,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ warning: unused variable: `foo`
--> $DIR/issue-62187-encountered-polymorphic-const.rs:15:9
|
LL | let foo = <[u8; 2]>::BIT_LEN;
| ^^^ help: consider prefixing with an underscore: `_foo`
| ^^^ help: if this is intentional, prefix it with an underscore: `_foo`
|
= note: `#[warn(unused_variables)]` on by default

4 changes: 2 additions & 2 deletions src/test/ui/issues/issue-17999.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error: unused variable: `x`
--> $DIR/issue-17999.rs:5:13
|
LL | let x = ();
| ^ help: consider prefixing with an underscore: `_x`
| ^ help: if this is intentional, prefix it with an underscore: `_x`
|
note: the lint level is defined here
--> $DIR/issue-17999.rs:1:9
Expand All @@ -14,7 +14,7 @@ error: unused variable: `a`
--> $DIR/issue-17999.rs:7:13
|
LL | a => {}
| ^ help: consider prefixing with an underscore: `_a`
| ^ help: if this is intentional, prefix it with an underscore: `_a`

error: aborting due to 2 previous errors

2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-22599.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error: unused variable: `a`
--> $DIR/issue-22599.rs:8:19
|
LL | v = match 0 { a => 0 };
| ^ help: consider prefixing with an underscore: `_a`
| ^ help: if this is intentional, prefix it with an underscore: `_a`
|
note: the lint level is defined here
--> $DIR/issue-22599.rs:1:9
Expand Down
12 changes: 6 additions & 6 deletions src/test/ui/issues/issue-56685.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ note: the lint level is defined here
|
LL | #![deny(unused_variables)]
| ^^^^^^^^^^^^^^^^
help: consider prefixing with an underscore
help: if this is intentional, prefix it with an underscore
|
LL | E::A(_x) | E::B(_x) => {}
| ^^ ^^
Expand All @@ -20,7 +20,7 @@ error: unused variable: `x`
LL | F::A(x, y) | F::B(x, y) => { y },
| ^ ^
|
help: consider prefixing with an underscore
help: if this is intentional, prefix it with an underscore
|
LL | F::A(_x, y) | F::B(_x, y) => { y },
| ^^ ^^
Expand All @@ -29,21 +29,21 @@ error: unused variable: `a`
--> $DIR/issue-56685.rs:27:14
|
LL | F::C(a, b) => { 3 }
| ^ help: consider prefixing with an underscore: `_a`
| ^ help: if this is intentional, prefix it with an underscore: `_a`

error: unused variable: `b`
--> $DIR/issue-56685.rs:27:17
|
LL | F::C(a, b) => { 3 }
| ^ help: consider prefixing with an underscore: `_b`
| ^ help: if this is intentional, prefix it with an underscore: `_b`

error: unused variable: `x`
--> $DIR/issue-56685.rs:32:25
|
LL | let _ = if let F::A(x, y) | F::B(x, y) = F::A(1, 2) {
| ^ ^
|
help: consider prefixing with an underscore
help: if this is intentional, prefix it with an underscore
|
LL | let _ = if let F::A(_x, y) | F::B(_x, y) = F::A(1, 2) {
| ^^ ^^
Expand All @@ -54,7 +54,7 @@ error: unused variable: `x`
LL | while let F::A(x, y) | F::B(x, y) = F::A(1, 2) {
| ^ ^
|
help: consider prefixing with an underscore
help: if this is intentional, prefix it with an underscore
|
LL | while let F::A(_x, y) | F::B(_x, y) = F::A(1, 2) {
| ^^ ^^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ warning: unused variable: `i_think_continually`
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:26:9
|
LL | let i_think_continually = 2;
| ^^^^^^^^^^^^^^^^^^^ help: consider prefixing with an underscore: `_i_think_continually`
| ^^^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_i_think_continually`
|
note: the lint level is defined here
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:5:9
Expand All @@ -15,19 +15,19 @@ warning: unused variable: `mut_unused_var`
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:33:13
|
LL | let mut mut_unused_var = 1;
| ^^^^^^^^^^^^^^ help: consider prefixing with an underscore: `_mut_unused_var`
| ^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_mut_unused_var`

warning: unused variable: `var`
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:37:14
|
LL | let (mut var, unused_var) = (1, 2);
| ^^^ help: consider prefixing with an underscore: `_var`
| ^^^ help: if this is intentional, prefix it with an underscore: `_var`

warning: unused variable: `unused_var`
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:37:19
|
LL | let (mut var, unused_var) = (1, 2);
| ^^^^^^^^^^ help: consider prefixing with an underscore: `_unused_var`
| ^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused_var`

warning: unused variable: `corridors_of_light`
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:45:26
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/lint/lint-match-arms.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error: unused variable: `y`
--> $DIR/lint-match-arms.rs:5:9
|
LL | y => (),
| ^ help: consider prefixing with an underscore: `_y`
| ^ help: if this is intentional, prefix it with an underscore: `_y`
|
note: the lint level is defined here
--> $DIR/lint-match-arms.rs:3:16
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/lint/lint-removed-allow.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error: unused variable: `unused`
--> $DIR/lint-removed-allow.rs:8:17
|
LL | fn main() { let unused = (); }
| ^^^^^^ help: consider prefixing with an underscore: `_unused`
| ^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused`
|
note: the lint level is defined here
--> $DIR/lint-removed-allow.rs:7:8
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/lint/lint-removed-cmdline.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ error: unused variable: `unused`
--> $DIR/lint-removed-cmdline.rs:12:17
|
LL | fn main() { let unused = (); }
| ^^^^^^ help: consider prefixing with an underscore: `_unused`
| ^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused`
|
note: the lint level is defined here
--> $DIR/lint-removed-cmdline.rs:11:8
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/lint/lint-removed.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ error: unused variable: `unused`
--> $DIR/lint-removed.rs:8:17
|
LL | fn main() { let unused = (); }
| ^^^^^^ help: consider prefixing with an underscore: `_unused`
| ^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused`
|
note: the lint level is defined here
--> $DIR/lint-removed.rs:7:8
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/lint/lint-renamed-allow.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error: unused variable: `unused`
--> $DIR/lint-renamed-allow.rs:8:17
|
LL | fn main() { let unused = (); }
| ^^^^^^ help: consider prefixing with an underscore: `_unused`
| ^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused`
|
note: the lint level is defined here
--> $DIR/lint-renamed-allow.rs:7:8
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/lint/lint-renamed-cmdline.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ error: unused variable: `unused`
--> $DIR/lint-renamed-cmdline.rs:8:17
|
LL | fn main() { let unused = (); }
| ^^^^^^ help: consider prefixing with an underscore: `_unused`
| ^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused`
|
note: the lint level is defined here
--> $DIR/lint-renamed-cmdline.rs:7:8
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/lint/lint-renamed.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ error: unused variable: `unused`
--> $DIR/lint-renamed.rs:4:17
|
LL | fn main() { let unused = (); }
| ^^^^^^ help: consider prefixing with an underscore: `_unused`
| ^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused`
|
note: the lint level is defined here
--> $DIR/lint-renamed.rs:3:8
Expand Down
22 changes: 11 additions & 11 deletions src/test/ui/lint/lint-unused-variables.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error: unused variable: `a`
--> $DIR/lint-unused-variables.rs:8:5
|
LL | a: i32,
| ^ help: consider prefixing with an underscore: `_a`
| ^ help: if this is intentional, prefix it with an underscore: `_a`
|
note: the lint level is defined here
--> $DIR/lint-unused-variables.rs:5:9
Expand All @@ -14,61 +14,61 @@ error: unused variable: `b`
--> $DIR/lint-unused-variables.rs:14:5
|
LL | b: i32,
| ^ help: consider prefixing with an underscore: `_b`
| ^ help: if this is intentional, prefix it with an underscore: `_b`

error: unused variable: `a`
--> $DIR/lint-unused-variables.rs:68:9
|
LL | a: i32,
| ^ help: consider prefixing with an underscore: `_a`
| ^ help: if this is intentional, prefix it with an underscore: `_a`

error: unused variable: `b`
--> $DIR/lint-unused-variables.rs:74:9
|
LL | b: i32,
| ^ help: consider prefixing with an underscore: `_b`
| ^ help: if this is intentional, prefix it with an underscore: `_b`

error: unused variable: `b`
--> $DIR/lint-unused-variables.rs:42:9
|
LL | b: i32,
| ^ help: consider prefixing with an underscore: `_b`
| ^ help: if this is intentional, prefix it with an underscore: `_b`

error: unused variable: `b`
--> $DIR/lint-unused-variables.rs:47:9
|
LL | b: i32,
| ^ help: consider prefixing with an underscore: `_b`
| ^ help: if this is intentional, prefix it with an underscore: `_b`

error: unused variable: `a`
--> $DIR/lint-unused-variables.rs:22:9
|
LL | a: i32,
| ^ help: consider prefixing with an underscore: `_a`
| ^ help: if this is intentional, prefix it with an underscore: `_a`

error: unused variable: `b`
--> $DIR/lint-unused-variables.rs:29:9
|
LL | b: i32,
| ^ help: consider prefixing with an underscore: `_b`
| ^ help: if this is intentional, prefix it with an underscore: `_b`

error: unused variable: `b`
--> $DIR/lint-unused-variables.rs:34:9
|
LL | b: i32,
| ^ help: consider prefixing with an underscore: `_b`
| ^ help: if this is intentional, prefix it with an underscore: `_b`

error: unused variable: `b`
--> $DIR/lint-unused-variables.rs:55:9
|
LL | b: i32,
| ^ help: consider prefixing with an underscore: `_b`
| ^ help: if this is intentional, prefix it with an underscore: `_b`

error: unused variable: `b`
--> $DIR/lint-unused-variables.rs:60:9
|
LL | b: i32,
| ^ help: consider prefixing with an underscore: `_b`
| ^ help: if this is intentional, prefix it with an underscore: `_b`

error: aborting due to 11 previous errors

6 changes: 3 additions & 3 deletions src/test/ui/lint/lint-uppercase-variables.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ warning: unused variable: `Foo`
--> $DIR/lint-uppercase-variables.rs:22:9
|
LL | Foo => {}
| ^^^ help: consider prefixing with an underscore: `_Foo`
| ^^^ help: if this is intentional, prefix it with an underscore: `_Foo`
|
note: the lint level is defined here
--> $DIR/lint-uppercase-variables.rs:1:9
Expand All @@ -35,13 +35,13 @@ warning: unused variable: `Foo`
--> $DIR/lint-uppercase-variables.rs:28:9
|
LL | let Foo = foo::Foo::Foo;
| ^^^ help: consider prefixing with an underscore: `_Foo`
| ^^^ help: if this is intentional, prefix it with an underscore: `_Foo`

warning: unused variable: `Foo`
--> $DIR/lint-uppercase-variables.rs:33:17
|
LL | fn in_param(Foo: foo::Foo) {}
| ^^^ help: consider prefixing with an underscore: `_Foo`
| ^^^ help: if this is intentional, prefix it with an underscore: `_Foo`

error: structure field `X` should have a snake case name
--> $DIR/lint-uppercase-variables.rs:10:5
Expand Down
16 changes: 8 additions & 8 deletions src/test/ui/liveness/liveness-unused.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ error: unused variable: `x`
--> $DIR/liveness-unused.rs:8:7
|
LL | fn f1(x: isize) {
| ^ help: consider prefixing with an underscore: `_x`
| ^ help: if this is intentional, prefix it with an underscore: `_x`
|
note: the lint level is defined here
--> $DIR/liveness-unused.rs:2:9
Expand All @@ -29,19 +29,19 @@ error: unused variable: `x`
--> $DIR/liveness-unused.rs:12:8
|
LL | fn f1b(x: &mut isize) {
| ^ help: consider prefixing with an underscore: `_x`
| ^ help: if this is intentional, prefix it with an underscore: `_x`

error: unused variable: `x`
--> $DIR/liveness-unused.rs:20:9
|
LL | let x: isize;
| ^ help: consider prefixing with an underscore: `_x`
| ^ help: if this is intentional, prefix it with an underscore: `_x`

error: unused variable: `x`
--> $DIR/liveness-unused.rs:25:9
|
LL | let x = 3;
| ^ help: consider prefixing with an underscore: `_x`
| ^ help: if this is intentional, prefix it with an underscore: `_x`

error: variable `x` is assigned to, but never used
--> $DIR/liveness-unused.rs:30:13
Expand Down Expand Up @@ -76,25 +76,25 @@ error: unused variable: `i`
--> $DIR/liveness-unused.rs:59:12
|
LL | Some(i) => {
| ^ help: consider prefixing with an underscore: `_i`
| ^ help: if this is intentional, prefix it with an underscore: `_i`

error: unused variable: `x`
--> $DIR/liveness-unused.rs:79:9
|
LL | for x in 1..10 { }
| ^ help: consider prefixing with an underscore: `_x`
| ^ help: if this is intentional, prefix it with an underscore: `_x`

error: unused variable: `x`
--> $DIR/liveness-unused.rs:84:10
|
LL | for (x, _) in [1, 2, 3].iter().enumerate() { }
| ^ help: consider prefixing with an underscore: `_x`
| ^ help: if this is intentional, prefix it with an underscore: `_x`

error: unused variable: `x`
--> $DIR/liveness-unused.rs:89:13
|
LL | for (_, x) in [1, 2, 3].iter().enumerate() {
| ^ help: consider prefixing with an underscore: `_x`
| ^ help: if this is intentional, prefix it with an underscore: `_x`

error: variable `x` is assigned to, but never used
--> $DIR/liveness-unused.rs:112:9
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/never_type/never-assign-dead-code.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ warning: unused variable: `x`
--> $DIR/never-assign-dead-code.rs:9:9
|
LL | let x: ! = panic!("aah");
| ^ help: consider prefixing with an underscore: `_x`
| ^ help: if this is intentional, prefix it with an underscore: `_x`
|
note: the lint level is defined here
--> $DIR/never-assign-dead-code.rs:6:9
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/proc-macro/attributes-included.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ warning: unused variable: `a`
--> $DIR/attributes-included.rs:17:9
|
LL | let a: i32 = "foo";
| ^ help: consider prefixing with an underscore: `_a`
| ^ help: if this is intentional, prefix it with an underscore: `_a`
|
note: the lint level is defined here
--> $DIR/attributes-included.rs:4:9
Expand Down
Loading

0 comments on commit b35c302

Please sign in to comment.