Skip to content

Commit 18b439f

Browse files
committed
Auto merge of #154605 - estebank:attr-suggest, r=jieyouxu
Make `span_suggestions` always verbose `span_suggestions` is to provide mutually exclusive suggestions. When it was introduced, we made its behavior be that if a single suggestion is given to it, we present the suggestion inline, otherwise in patch format. Changing this to make all of its uses be verbose, as that is closer in intent of output.
2 parents e8e4541 + b849e10 commit 18b439f

74 files changed

Lines changed: 1735 additions & 722 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

compiler/rustc_errors/src/diagnostic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
983983
msg,
984984
suggestions,
985985
applicability,
986-
SuggestionStyle::ShowCode,
986+
SuggestionStyle::ShowAlways,
987987
)
988988
} }
989989

src/tools/clippy/tests/ui/blocks_in_conditions.stderr

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,15 @@ error: this boolean expression can be simplified
2929
--> tests/ui/blocks_in_conditions.rs:48:8
3030
|
3131
LL | if true && x == 3 { 6 } else { 10 }
32-
| ^^^^^^^^^^^^^^ help: try: `x == 3`
32+
| ^^^^^^^^^^^^^^
3333
|
3434
= note: `-D clippy::nonminimal-bool` implied by `-D warnings`
3535
= help: to override `-D warnings` add `#[allow(clippy::nonminimal_bool)]`
36+
help: try
37+
|
38+
LL - if true && x == 3 { 6 } else { 10 }
39+
LL + if x == 3 { 6 } else { 10 }
40+
|
3641

3742
error: aborting due to 3 previous errors
3843

src/tools/clippy/tests/ui/crashes/ice-96721.stderr

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@ error: malformed `path` attribute input
22
--> tests/ui/crashes/ice-96721.rs:7:1
33
|
44
LL | #[path = foo!()]
5-
| ^^^^^^^^^^^^^^^^ help: must be of the form: `#[path = "file"]`
5+
| ^^^^^^^^^^^^^^^^
66
|
77
= note: for more information, visit <https://doc.rust-lang.org/reference/items/modules.html#the-path-attribute>
8+
help: must be of the form
9+
|
10+
LL - #[path = foo!()]
11+
LL + #[path = "file"]
12+
|
813

914
error: aborting due to 1 previous error
1015

src/tools/clippy/tests/ui/nonminimal_bool.stderr

Lines changed: 69 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,87 @@ error: this boolean expression can be simplified
22
--> tests/ui/nonminimal_bool.rs:17:13
33
|
44
LL | let _ = !true;
5-
| ^^^^^ help: try: `false`
5+
| ^^^^^
66
|
77
= note: `-D clippy::nonminimal-bool` implied by `-D warnings`
88
= help: to override `-D warnings` add `#[allow(clippy::nonminimal_bool)]`
9+
help: try
10+
|
11+
LL - let _ = !true;
12+
LL + let _ = false;
13+
|
914

1015
error: this boolean expression can be simplified
1116
--> tests/ui/nonminimal_bool.rs:20:13
1217
|
1318
LL | let _ = !false;
14-
| ^^^^^^ help: try: `true`
19+
| ^^^^^^
20+
|
21+
help: try
22+
|
23+
LL - let _ = !false;
24+
LL + let _ = true;
25+
|
1526

1627
error: this boolean expression can be simplified
1728
--> tests/ui/nonminimal_bool.rs:23:13
1829
|
1930
LL | let _ = !!a;
20-
| ^^^ help: try: `a`
31+
| ^^^
32+
|
33+
help: try
34+
|
35+
LL - let _ = !!a;
36+
LL + let _ = a;
37+
|
2138

2239
error: this boolean expression can be simplified
2340
--> tests/ui/nonminimal_bool.rs:26:13
2441
|
2542
LL | let _ = false || a;
26-
| ^^^^^^^^^^ help: try: `a`
43+
| ^^^^^^^^^^
44+
|
45+
help: try
46+
|
47+
LL - let _ = false || a;
48+
LL + let _ = a;
49+
|
2750

2851
error: this boolean expression can be simplified
2952
--> tests/ui/nonminimal_bool.rs:32:13
3053
|
3154
LL | let _ = !(!a && b);
32-
| ^^^^^^^^^^ help: try: `a || !b`
55+
| ^^^^^^^^^^
56+
|
57+
help: try
58+
|
59+
LL - let _ = !(!a && b);
60+
LL + let _ = a || !b;
61+
|
3362

3463
error: this boolean expression can be simplified
3564
--> tests/ui/nonminimal_bool.rs:35:13
3665
|
3766
LL | let _ = !(!a || b);
38-
| ^^^^^^^^^^ help: try: `a && !b`
67+
| ^^^^^^^^^^
68+
|
69+
help: try
70+
|
71+
LL - let _ = !(!a || b);
72+
LL + let _ = a && !b;
73+
|
3974

4075
error: this boolean expression can be simplified
4176
--> tests/ui/nonminimal_bool.rs:38:13
4277
|
4378
LL | let _ = !a && !(b && c);
44-
| ^^^^^^^^^^^^^^^ help: try: `!(a || b && c)`
79+
| ^^^^^^^^^^^^^^^
80+
|
81+
help: try
82+
|
83+
LL - let _ = !a && !(b && c);
84+
LL + let _ = !(a || b && c);
85+
|
4586

4687
error: this boolean expression can be simplified
4788
--> tests/ui/nonminimal_bool.rs:47:13
@@ -122,7 +163,13 @@ error: this boolean expression can be simplified
122163
--> tests/ui/nonminimal_bool.rs:90:8
123164
|
124165
LL | if matches!(true, true) && true {
125-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `matches!(true, true)`
166+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
167+
|
168+
help: try
169+
|
170+
LL - if matches!(true, true) && true {
171+
LL + if matches!(true, true) {
172+
|
126173

127174
error: this boolean expression can be simplified
128175
--> tests/ui/nonminimal_bool.rs:171:8
@@ -215,13 +262,25 @@ error: this boolean expression can be simplified
215262
--> tests/ui/nonminimal_bool.rs:212:8
216263
|
217264
LL | if !(a < 2.0 && !b) {
218-
| ^^^^^^^^^^^^^^^^ help: try: `a >= 2.0 || b`
265+
| ^^^^^^^^^^^^^^^^
266+
|
267+
help: try
268+
|
269+
LL - if !(a < 2.0 && !b) {
270+
LL + if a >= 2.0 || b {
271+
|
219272

220273
error: this boolean expression can be simplified
221274
--> tests/ui/nonminimal_bool.rs:231:12
222275
|
223276
LL | if !(matches!(ty, TyKind::Ref(_, _, _)) && !is_mutable(&expr)) {
224-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `!matches!(ty, TyKind::Ref(_, _, _)) || is_mutable(&expr)`
277+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
278+
|
279+
help: try
280+
|
281+
LL - if !(matches!(ty, TyKind::Ref(_, _, _)) && !is_mutable(&expr)) {
282+
LL + if !matches!(ty, TyKind::Ref(_, _, _)) || is_mutable(&expr) {
283+
|
225284

226285
error: this boolean expression can be simplified
227286
--> tests/ui/nonminimal_bool.rs:251:8

src/tools/clippy/tests/ui/nonminimal_bool_methods.stderr

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,25 @@ error: this boolean expression can be simplified
2929
--> tests/ui/nonminimal_bool_methods.rs:20:13
3030
|
3131
LL | let _ = !(a.is_some() && !c);
32-
| ^^^^^^^^^^^^^^^^^^^^ help: try: `a.is_none() || c`
32+
| ^^^^^^^^^^^^^^^^^^^^
33+
|
34+
help: try
35+
|
36+
LL - let _ = !(a.is_some() && !c);
37+
LL + let _ = a.is_none() || c;
38+
|
3339

3440
error: this boolean expression can be simplified
3541
--> tests/ui/nonminimal_bool_methods.rs:22:13
3642
|
3743
LL | let _ = !(a.is_some() || !c);
38-
| ^^^^^^^^^^^^^^^^^^^^ help: try: `a.is_none() && c`
44+
| ^^^^^^^^^^^^^^^^^^^^
45+
|
46+
help: try
47+
|
48+
LL - let _ = !(a.is_some() || !c);
49+
LL + let _ = a.is_none() && c;
50+
|
3951

4052
error: this boolean expression can be simplified
4153
--> tests/ui/nonminimal_bool_methods.rs:24:26

tests/ui/allocator/allocator-args.stderr

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ error: malformed `global_allocator` attribute input
22
--> $DIR/allocator-args.rs:10:1
33
|
44
LL | #[global_allocator(malloc)]
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[global_allocator]`
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
help: must be of the form
8+
|
9+
LL - #[global_allocator(malloc)]
10+
LL + #[global_allocator]
11+
|
612

713
error: aborting due to 1 previous error
814

tests/ui/attributes/crate-type-delimited.stderr

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@ error[E0539]: malformed `crate_type` attribute input
22
--> $DIR/crate-type-delimited.rs:2:1
33
|
44
LL | #![crate_type(lib)]
5-
| ^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![crate_type = "crate type"]`
5+
| ^^^^^^^^^^^^^^^^^^^
66
|
77
= note: for more information, visit <https://doc.rust-lang.org/reference/linkage.html>
8+
help: must be of the form
9+
|
10+
LL - #![crate_type(lib)]
11+
LL + #![crate_type = "crate type"]
12+
|
813

914
error: aborting due to 1 previous error
1015

tests/ui/attributes/crate-type-empty.stderr

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ error[E0539]: malformed `crate_type` attribute input
22
--> $DIR/crate-type-empty.rs:2:1
33
|
44
LL | #![crate_type]
5-
| ^^^^^^^^^^^^^^ help: must be of the form: `#![crate_type = "crate type"]`
5+
| ^^^^^^^^^^^^^^
66
|
77
= note: for more information, visit <https://doc.rust-lang.org/reference/linkage.html>
8+
help: must be of the form
9+
|
10+
LL | #![crate_type = "crate type"]
11+
| ++++++++++++++
812

913
error: aborting due to 1 previous error
1014

tests/ui/attributes/crate-type-non-crate.stderr

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,39 @@ error[E0539]: malformed `crate_type` attribute input
22
--> $DIR/crate-type-non-crate.rs:5:1
33
|
44
LL | #[crate_type]
5-
| ^^^^^^^^^^^^^ help: must be of the form: `#[crate_type = "crate type"]`
5+
| ^^^^^^^^^^^^^
66
|
77
= note: for more information, visit <https://doc.rust-lang.org/reference/linkage.html>
8+
help: must be of the form
9+
|
10+
LL | #[crate_type = "crate type"]
11+
| ++++++++++++++
812

913
error[E0539]: malformed `crate_type` attribute input
1014
--> $DIR/crate-type-non-crate.rs:7:1
1115
|
1216
LL | #[crate_type(lib)]
13-
| ^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[crate_type = "crate type"]`
17+
| ^^^^^^^^^^^^^^^^^^
1418
|
1519
= note: for more information, visit <https://doc.rust-lang.org/reference/linkage.html>
20+
help: must be of the form
21+
|
22+
LL - #[crate_type(lib)]
23+
LL + #[crate_type = "crate type"]
24+
|
1625

1726
error[E0539]: malformed `crate_type` attribute input
1827
--> $DIR/crate-type-non-crate.rs:8:1
1928
|
2029
LL | #[crate_type("lib")]
21-
| ^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[crate_type = "crate type"]`
30+
| ^^^^^^^^^^^^^^^^^^^^
2231
|
2332
= note: for more information, visit <https://doc.rust-lang.org/reference/linkage.html>
33+
help: must be of the form
34+
|
35+
LL - #[crate_type("lib")]
36+
LL + #[crate_type = "crate type"]
37+
|
2438

2539
error: attribute value must be a literal
2640
--> $DIR/crate-type-non-crate.rs:9:16
@@ -32,17 +46,27 @@ error[E0539]: malformed `crate_type` attribute input
3246
--> $DIR/crate-type-non-crate.rs:12:1
3347
|
3448
LL | #[crate_type(foo)]
35-
| ^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[crate_type = "crate type"]`
49+
| ^^^^^^^^^^^^^^^^^^
3650
|
3751
= note: for more information, visit <https://doc.rust-lang.org/reference/linkage.html>
52+
help: must be of the form
53+
|
54+
LL - #[crate_type(foo)]
55+
LL + #[crate_type = "crate type"]
56+
|
3857

3958
error[E0539]: malformed `crate_type` attribute input
4059
--> $DIR/crate-type-non-crate.rs:13:1
4160
|
4261
LL | #[crate_type("foo")]
43-
| ^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[crate_type = "crate type"]`
62+
| ^^^^^^^^^^^^^^^^^^^^
4463
|
4564
= note: for more information, visit <https://doc.rust-lang.org/reference/linkage.html>
65+
help: must be of the form
66+
|
67+
LL - #[crate_type("foo")]
68+
LL + #[crate_type = "crate type"]
69+
|
4670

4771
error: attribute value must be a literal
4872
--> $DIR/crate-type-non-crate.rs:14:16
@@ -54,20 +78,29 @@ error[E0539]: malformed `crate_type` attribute input
5478
--> $DIR/crate-type-non-crate.rs:17:1
5579
|
5680
LL | #[crate_type(1)]
57-
| ^^^^^^^^^^^^^^^^ help: must be of the form: `#[crate_type = "crate type"]`
81+
| ^^^^^^^^^^^^^^^^
5882
|
5983
= note: for more information, visit <https://doc.rust-lang.org/reference/linkage.html>
84+
help: must be of the form
85+
|
86+
LL - #[crate_type(1)]
87+
LL + #[crate_type = "crate type"]
88+
|
6089

6190
error[E0539]: malformed `crate_type` attribute input
6291
--> $DIR/crate-type-non-crate.rs:18:1
6392
|
6493
LL | #[crate_type = 1]
6594
| ^^^^^^^^^^^^^^^-^
66-
| | |
67-
| | expected a string literal here
68-
| help: must be of the form: `#[crate_type = "crate type"]`
95+
| |
96+
| expected a string literal here
6997
|
7098
= note: for more information, visit <https://doc.rust-lang.org/reference/linkage.html>
99+
help: must be of the form
100+
|
101+
LL - #[crate_type = 1]
102+
LL + #[crate_type = "crate type"]
103+
|
71104

72105
error: aborting due to 9 previous errors
73106

tests/ui/attributes/expected-word.stderr

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@ error[E0565]: malformed `cold` attribute input
33
|
44
LL | #[cold = true]
55
| ^^^^^^^------^
6-
| | |
7-
| | didn't expect any arguments here
8-
| help: must be of the form: `#[cold]`
6+
| |
7+
| didn't expect any arguments here
8+
|
9+
help: must be of the form
10+
|
11+
LL - #[cold = true]
12+
LL + #[cold]
13+
|
914

1015
error: aborting due to 1 previous error
1116

0 commit comments

Comments
 (0)