Skip to content

Commit d7307a7

Browse files
committed
Always show suggestions in their own subwindows
1 parent 1bce775 commit d7307a7

File tree

8 files changed

+69
-47
lines changed

8 files changed

+69
-47
lines changed

compiler/rustc_typeck/src/check/pat.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10611061
wildcard_sugg = String::from(", ") + &wildcard_sugg;
10621062
}
10631063

1064-
err.span_suggestion_short(
1064+
err.span_suggestion_verbose(
10651065
after_fields_span,
10661066
"use `_` to explicitly ignore each field",
10671067
wildcard_sugg,
@@ -1071,14 +1071,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10711071
// Only suggest `..` if more than one field is missing.
10721072
if fields.len() - subpats.len() > 1 {
10731073
if subpats.is_empty() || all_wildcards {
1074-
err.span_suggestion_short(
1074+
err.span_suggestion_verbose(
10751075
all_fields_span,
10761076
"use `..` to ignore all fields",
10771077
String::from(".."),
10781078
Applicability::MaybeIncorrect,
10791079
);
10801080
} else {
1081-
err.span_suggestion_short(
1081+
err.span_suggestion_verbose(
10821082
after_fields_span,
10831083
"use `..` to ignore the rest of the fields",
10841084
String::from(", .."),

src/test/ui/destructuring-assignment/tuple_struct_destructure_fail.stderr

+12-8
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ LL | struct TupleStruct<S, T>(S, T);
3030
| ------------------------------- tuple struct defined here
3131
...
3232
LL | TupleStruct(_) = TupleStruct(1, 2);
33-
| ^^^^^^^^^^^^^-
34-
| | |
35-
| | help: use `_` to explicitly ignore each field
36-
| expected 2 fields, found 1
33+
| ^^^^^^^^^^^^^^ expected 2 fields, found 1
34+
|
35+
help: use `_` to explicitly ignore each field
36+
|
37+
LL | TupleStruct(_, _) = TupleStruct(1, 2);
38+
| ^^^
3739

3840
error[E0023]: this pattern has 3 fields, but the corresponding tuple variant has 2 fields
3941
--> $DIR/tuple_struct_destructure_fail.rs:34:5
@@ -51,10 +53,12 @@ LL | SingleVariant(S, T)
5153
| ------------------- tuple variant defined here
5254
...
5355
LL | Enum::SingleVariant(_) = Enum::SingleVariant(1, 2);
54-
| ^^^^^^^^^^^^^^^^^^^^^-
55-
| | |
56-
| | help: use `_` to explicitly ignore each field
57-
| expected 2 fields, found 1
56+
| ^^^^^^^^^^^^^^^^^^^^^^ expected 2 fields, found 1
57+
|
58+
help: use `_` to explicitly ignore each field
59+
|
60+
LL | Enum::SingleVariant(_, _) = Enum::SingleVariant(1, 2);
61+
| ^^^
5862

5963
error[E0070]: invalid left-hand side of assignment
6064
--> $DIR/tuple_struct_destructure_fail.rs:40:12

src/test/ui/error-codes/E0023.stderr

+6-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ LL | Apple(String, String),
55
| --------------------- tuple variant defined here
66
...
77
LL | Fruit::Apple(a) => {},
8-
| ^^^^^^^^^^^^^^-
9-
| | |
10-
| | help: use `_` to explicitly ignore each field
11-
| expected 2 fields, found 1
8+
| ^^^^^^^^^^^^^^^ expected 2 fields, found 1
9+
|
10+
help: use `_` to explicitly ignore each field
11+
|
12+
LL | Fruit::Apple(a, _) => {},
13+
| ^^^
1214

1315
error[E0023]: this pattern has 3 fields, but the corresponding tuple variant has 2 fields
1416
--> $DIR/E0023.rs:12:9

src/test/ui/issues/issue-67037-pat-tup-scrut-ty-diff-less-fields.stderr

+6-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ LL | struct P<T>(T); // 1 type parameter wanted
1616
| --------------- tuple struct defined here
1717
...
1818
LL | let P() = U {};
19-
| ^^-
20-
| | |
21-
| | help: use `_` to explicitly ignore each field
22-
| expected 1 field, found 0
19+
| ^^^ expected 1 field, found 0
20+
|
21+
help: use `_` to explicitly ignore each field
22+
|
23+
LL | let P(_) = U {};
24+
| ^
2325

2426
error: aborting due to 2 previous errors
2527

src/test/ui/issues/issue-72574-2.stderr

+6-4
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ LL | struct Binder(i32, i32, i32);
2525
| ----------------------------- tuple struct defined here
2626
...
2727
LL | Binder(_a, _x @ ..) => {}
28-
| ^^^^^^^^^^^^^^^^^^-
29-
| | |
30-
| | help: use `_` to explicitly ignore each field
31-
| expected 3 fields, found 2
28+
| ^^^^^^^^^^^^^^^^^^^ expected 3 fields, found 2
29+
|
30+
help: use `_` to explicitly ignore each field
31+
|
32+
LL | Binder(_a, _x @ .., _) => {}
33+
| ^^^
3234

3335
error: aborting due to 3 previous errors
3436

src/test/ui/match/match-pattern-field-mismatch.stderr

+6-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ LL | Rgb(usize, usize, usize),
55
| ------------------------ tuple variant defined here
66
...
77
LL | Color::Rgb(_, _) => { }
8-
| ^^^^^^^^^^^^^^^-
9-
| | |
10-
| | help: use `_` to explicitly ignore each field
11-
| expected 3 fields, found 2
8+
| ^^^^^^^^^^^^^^^^ expected 3 fields, found 2
9+
|
10+
help: use `_` to explicitly ignore each field
11+
|
12+
LL | Color::Rgb(_, _, _) => { }
13+
| ^^^
1214

1315
error: aborting due to previous error
1416

src/test/ui/pattern/issue-74539.stderr

+6-4
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ LL | A(u8, u8),
2525
| --------- tuple variant defined here
2626
...
2727
LL | E::A(x @ ..) => {
28-
| ^^^^^^^^^^^-
29-
| | |
30-
| | help: use `_` to explicitly ignore each field
31-
| expected 2 fields, found 1
28+
| ^^^^^^^^^^^^ expected 2 fields, found 1
29+
|
30+
help: use `_` to explicitly ignore each field
31+
|
32+
LL | E::A(x @ .., _) => {
33+
| ^^^
3234

3335
error: aborting due to 3 previous errors
3436

src/test/ui/pattern/pat-tuple-underfield.stderr

+24-16
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ LL | struct S(i32, f32);
1414
| ------------------- tuple struct defined here
1515
...
1616
LL | S(x) => {}
17-
| ^^^-
18-
| | |
19-
| | help: use `_` to explicitly ignore each field
20-
| expected 2 fields, found 1
17+
| ^^^^ expected 2 fields, found 1
18+
|
19+
help: use `_` to explicitly ignore each field
20+
|
21+
LL | S(x, _) => {}
22+
| ^^^
2123

2224
error[E0023]: this pattern has 1 field, but the corresponding tuple struct has 2 fields
2325
--> $DIR/pat-tuple-underfield.rs:14:9
@@ -26,10 +28,12 @@ LL | struct S(i32, f32);
2628
| ------------------- tuple struct defined here
2729
...
2830
LL | S(_) => {}
29-
| ^^^-
30-
| | |
31-
| | help: use `_` to explicitly ignore each field
32-
| expected 2 fields, found 1
31+
| ^^^^ expected 2 fields, found 1
32+
|
33+
help: use `_` to explicitly ignore each field
34+
|
35+
LL | S(_, _) => {}
36+
| ^^^
3337

3438
error[E0023]: this pattern has 0 fields, but the corresponding tuple struct has 2 fields
3539
--> $DIR/pat-tuple-underfield.rs:19:9
@@ -56,10 +60,12 @@ LL | S(i32, f32),
5660
| ----------- tuple variant defined here
5761
...
5862
LL | E::S(x) => {}
59-
| ^^^^^^-
60-
| | |
61-
| | help: use `_` to explicitly ignore each field
62-
| expected 2 fields, found 1
63+
| ^^^^^^^ expected 2 fields, found 1
64+
|
65+
help: use `_` to explicitly ignore each field
66+
|
67+
LL | E::S(x, _) => {}
68+
| ^^^
6369

6470
error[E0023]: this pattern has 1 field, but the corresponding tuple variant has 2 fields
6571
--> $DIR/pat-tuple-underfield.rs:31:9
@@ -68,10 +74,12 @@ LL | S(i32, f32),
6874
| ----------- tuple variant defined here
6975
...
7076
LL | E::S(_) => {}
71-
| ^^^^^^-
72-
| | |
73-
| | help: use `_` to explicitly ignore each field
74-
| expected 2 fields, found 1
77+
| ^^^^^^^ expected 2 fields, found 1
78+
|
79+
help: use `_` to explicitly ignore each field
80+
|
81+
LL | E::S(_, _) => {}
82+
| ^^^
7583

7684
error[E0023]: this pattern has 0 fields, but the corresponding tuple variant has 2 fields
7785
--> $DIR/pat-tuple-underfield.rs:36:9

0 commit comments

Comments
 (0)