Skip to content

Commit 1bb0c92

Browse files
authored
Rollup merge of #70300 - aleksator:66636_reword_unused_variable_warning, r=Dylan-DPC
Reword unused variable warning Fixes #66636
2 parents 8cb3daa + b35c302 commit 1bb0c92

22 files changed

+69
-69
lines changed

src/doc/rustc/src/json.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ Diagnostics have the following format:
168168
"rendered": null
169169
},
170170
{
171-
"message": "consider prefixing with an underscore",
171+
"message": "if this is intentional, prefix it with an underscore",
172172
"code": null,
173173
"level": "help",
174174
"spans": [
@@ -201,7 +201,7 @@ Diagnostics have the following format:
201201
/* Optional string of the rendered version of the diagnostic as displayed
202202
by rustc. Note that this may be influenced by the `--json` flag.
203203
*/
204-
"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"
204+
"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"
205205
}
206206
```
207207

src/librustc_passes/liveness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1565,7 +1565,7 @@ impl<'tcx> Liveness<'_, 'tcx> {
15651565
}
15661566
} else {
15671567
err.multipart_suggestion(
1568-
"consider prefixing with an underscore",
1568+
"if this is intentional, prefix it with an underscore",
15691569
spans.iter().map(|span| (*span, format!("_{}", name))).collect(),
15701570
Applicability::MachineApplicable,
15711571
);

src/test/ui/const-generics/issues/issue-62187-encountered-polymorphic-const.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ warning: unused variable: `foo`
1010
--> $DIR/issue-62187-encountered-polymorphic-const.rs:15:9
1111
|
1212
LL | let foo = <[u8; 2]>::BIT_LEN;
13-
| ^^^ help: consider prefixing with an underscore: `_foo`
13+
| ^^^ help: if this is intentional, prefix it with an underscore: `_foo`
1414
|
1515
= note: `#[warn(unused_variables)]` on by default
1616

src/test/ui/issues/issue-17999.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: unused variable: `x`
22
--> $DIR/issue-17999.rs:5:13
33
|
44
LL | let x = ();
5-
| ^ help: consider prefixing with an underscore: `_x`
5+
| ^ help: if this is intentional, prefix it with an underscore: `_x`
66
|
77
note: the lint level is defined here
88
--> $DIR/issue-17999.rs:1:9
@@ -14,7 +14,7 @@ error: unused variable: `a`
1414
--> $DIR/issue-17999.rs:7:13
1515
|
1616
LL | a => {}
17-
| ^ help: consider prefixing with an underscore: `_a`
17+
| ^ help: if this is intentional, prefix it with an underscore: `_a`
1818

1919
error: aborting due to 2 previous errors
2020

src/test/ui/issues/issue-22599.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: unused variable: `a`
22
--> $DIR/issue-22599.rs:8:19
33
|
44
LL | v = match 0 { a => 0 };
5-
| ^ help: consider prefixing with an underscore: `_a`
5+
| ^ help: if this is intentional, prefix it with an underscore: `_a`
66
|
77
note: the lint level is defined here
88
--> $DIR/issue-22599.rs:1:9

src/test/ui/issues/issue-56685.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ note: the lint level is defined here
99
|
1010
LL | #![deny(unused_variables)]
1111
| ^^^^^^^^^^^^^^^^
12-
help: consider prefixing with an underscore
12+
help: if this is intentional, prefix it with an underscore
1313
|
1414
LL | E::A(_x) | E::B(_x) => {}
1515
| ^^ ^^
@@ -20,7 +20,7 @@ error: unused variable: `x`
2020
LL | F::A(x, y) | F::B(x, y) => { y },
2121
| ^ ^
2222
|
23-
help: consider prefixing with an underscore
23+
help: if this is intentional, prefix it with an underscore
2424
|
2525
LL | F::A(_x, y) | F::B(_x, y) => { y },
2626
| ^^ ^^
@@ -29,21 +29,21 @@ error: unused variable: `a`
2929
--> $DIR/issue-56685.rs:27:14
3030
|
3131
LL | F::C(a, b) => { 3 }
32-
| ^ help: consider prefixing with an underscore: `_a`
32+
| ^ help: if this is intentional, prefix it with an underscore: `_a`
3333

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

4040
error: unused variable: `x`
4141
--> $DIR/issue-56685.rs:32:25
4242
|
4343
LL | let _ = if let F::A(x, y) | F::B(x, y) = F::A(1, 2) {
4444
| ^ ^
4545
|
46-
help: consider prefixing with an underscore
46+
help: if this is intentional, prefix it with an underscore
4747
|
4848
LL | let _ = if let F::A(_x, y) | F::B(_x, y) = F::A(1, 2) {
4949
| ^^ ^^
@@ -54,7 +54,7 @@ error: unused variable: `x`
5454
LL | while let F::A(x, y) | F::B(x, y) = F::A(1, 2) {
5555
| ^ ^
5656
|
57-
help: consider prefixing with an underscore
57+
help: if this is intentional, prefix it with an underscore
5858
|
5959
LL | while let F::A(_x, y) | F::B(_x, y) = F::A(1, 2) {
6060
| ^^ ^^

src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ warning: unused variable: `i_think_continually`
22
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:26:9
33
|
44
LL | let i_think_continually = 2;
5-
| ^^^^^^^^^^^^^^^^^^^ help: consider prefixing with an underscore: `_i_think_continually`
5+
| ^^^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_i_think_continually`
66
|
77
note: the lint level is defined here
88
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:5:9
@@ -15,19 +15,19 @@ warning: unused variable: `mut_unused_var`
1515
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:33:13
1616
|
1717
LL | let mut mut_unused_var = 1;
18-
| ^^^^^^^^^^^^^^ help: consider prefixing with an underscore: `_mut_unused_var`
18+
| ^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_mut_unused_var`
1919

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

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

3232
warning: unused variable: `corridors_of_light`
3333
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:45:26

src/test/ui/lint/lint-match-arms.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: unused variable: `y`
22
--> $DIR/lint-match-arms.rs:5:9
33
|
44
LL | y => (),
5-
| ^ help: consider prefixing with an underscore: `_y`
5+
| ^ help: if this is intentional, prefix it with an underscore: `_y`
66
|
77
note: the lint level is defined here
88
--> $DIR/lint-match-arms.rs:3:16

src/test/ui/lint/lint-removed-allow.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: unused variable: `unused`
22
--> $DIR/lint-removed-allow.rs:8:17
33
|
44
LL | fn main() { let unused = (); }
5-
| ^^^^^^ help: consider prefixing with an underscore: `_unused`
5+
| ^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused`
66
|
77
note: the lint level is defined here
88
--> $DIR/lint-removed-allow.rs:7:8

src/test/ui/lint/lint-removed-cmdline.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ error: unused variable: `unused`
1818
--> $DIR/lint-removed-cmdline.rs:12:17
1919
|
2020
LL | fn main() { let unused = (); }
21-
| ^^^^^^ help: consider prefixing with an underscore: `_unused`
21+
| ^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused`
2222
|
2323
note: the lint level is defined here
2424
--> $DIR/lint-removed-cmdline.rs:11:8

0 commit comments

Comments
 (0)