Skip to content

Commit 069199a

Browse files
committed
Use verbose suggestion for variant rename
1 parent 9a07a7c commit 069199a

File tree

8 files changed

+79
-34
lines changed

8 files changed

+79
-34
lines changed

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
11101110
assoc_ident.name,
11111111
None,
11121112
) {
1113-
err.span_suggestion(
1113+
err.span_suggestion_verbose(
11141114
assoc_ident.span,
11151115
"there is a variant with a similar name",
11161116
suggested_name,

compiler/rustc_hir_typeck/src/method/suggest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1601,7 +1601,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16011601
item_name.name,
16021602
None,
16031603
) {
1604-
err.span_suggestion(
1604+
err.span_suggestion_verbose(
16051605
span,
16061606
"there is a variant with a similar name",
16071607
suggestion,

tests/ui/empty/empty-struct-braces-expr.stderr

+21-9
Original file line numberDiff line numberDiff line change
@@ -112,25 +112,37 @@ error[E0599]: no variant or associated item named `Empty3` found for enum `empty
112112
--> $DIR/empty-struct-braces-expr.rs:25:19
113113
|
114114
LL | let xe3 = XE::Empty3;
115-
| ^^^^^^
116-
| |
117-
| variant or associated item not found in `XE`
118-
| help: there is a variant with a similar name: `XEmpty3`
115+
| ^^^^^^ variant or associated item not found in `XE`
116+
|
117+
help: there is a variant with a similar name
118+
|
119+
LL - let xe3 = XE::Empty3;
120+
LL + let xe3 = XE::XEmpty3;
121+
|
119122

120123
error[E0599]: no variant or associated item named `Empty3` found for enum `empty_struct::XE` in the current scope
121124
--> $DIR/empty-struct-braces-expr.rs:26:19
122125
|
123126
LL | let xe3 = XE::Empty3();
124-
| ^^^^^^
125-
| |
126-
| variant or associated item not found in `XE`
127-
| help: there is a variant with a similar name: `XEmpty3`
127+
| ^^^^^^ variant or associated item not found in `XE`
128+
|
129+
help: there is a variant with a similar name
130+
|
131+
LL - let xe3 = XE::Empty3();
132+
LL + let xe3 = XE::XEmpty3();
133+
|
128134

129135
error[E0599]: no variant named `Empty1` found for enum `empty_struct::XE`
130136
--> $DIR/empty-struct-braces-expr.rs:28:9
131137
|
132138
LL | XE::Empty1 {};
133-
| ^^^^^^ help: there is a variant with a similar name: `XEmpty3`
139+
| ^^^^^^
140+
|
141+
help: there is a variant with a similar name
142+
|
143+
LL - XE::Empty1 {};
144+
LL + XE::XEmpty3 {};
145+
|
134146

135147
error: aborting due to 9 previous errors
136148

tests/ui/expr/issue-22933-2.stderr

+7-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ LL | enum Delicious {
55
| -------------- variant or associated item `PIE` not found for this enum
66
...
77
LL | ApplePie = Delicious::Apple as isize | Delicious::PIE as isize,
8-
| ^^^
9-
| |
10-
| variant or associated item not found in `Delicious`
11-
| help: there is a variant with a similar name: `Pie`
8+
| ^^^ variant or associated item not found in `Delicious`
9+
|
10+
help: there is a variant with a similar name
11+
|
12+
LL - ApplePie = Delicious::Apple as isize | Delicious::PIE as isize,
13+
LL + ApplePie = Delicious::Apple as isize | Delicious::Pie as isize,
14+
|
1215

1316
error: aborting due to 1 previous error
1417

tests/ui/issues/issue-23217.stderr

+7-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ error[E0599]: no variant or associated item named `A` found for enum `SomeEnum`
44
LL | pub enum SomeEnum {
55
| ----------------- variant or associated item `A` not found for this enum
66
LL | B = SomeEnum::A,
7-
| ^
8-
| |
9-
| variant or associated item not found in `SomeEnum`
10-
| help: there is a variant with a similar name: `B`
7+
| ^ variant or associated item not found in `SomeEnum`
8+
|
9+
help: there is a variant with a similar name
10+
|
11+
LL - B = SomeEnum::A,
12+
LL + B = SomeEnum::B,
13+
|
1114

1215
error: aborting due to 1 previous error
1316

tests/ui/issues/issue-28971.stderr

+7-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ LL | enum Foo {
55
| -------- variant or associated item `Baz` not found for this enum
66
...
77
LL | Foo::Baz(..) => (),
8-
| ^^^
9-
| |
10-
| variant or associated item not found in `Foo`
11-
| help: there is a variant with a similar name: `Bar`
8+
| ^^^ variant or associated item not found in `Foo`
9+
|
10+
help: there is a variant with a similar name
11+
|
12+
LL - Foo::Baz(..) => (),
13+
LL + Foo::Bar(..) => (),
14+
|
1215

1316
error[E0596]: cannot borrow `f` as mutable, as it is not declared as mutable
1417
--> $DIR/issue-28971.rs:15:5

tests/ui/issues/issue-34209.stderr

+7-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ LL | enum S {
55
| ------ variant `B` not found here
66
...
77
LL | S::B {} => {},
8-
| ^ help: there is a variant with a similar name: `A`
8+
| ^
9+
|
10+
help: there is a variant with a similar name
11+
|
12+
LL - S::B {} => {},
13+
LL + S::A {} => {},
14+
|
915

1016
error: aborting due to 1 previous error
1117

tests/ui/suggestions/suggest-variants.stderr

+28-10
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ LL | enum Shape {
55
| ---------- variant `Squareee` not found here
66
...
77
LL | println!("My shape is {:?}", Shape::Squareee { size: 5});
8-
| ^^^^^^^^ help: there is a variant with a similar name: `Square`
8+
| ^^^^^^^^
9+
|
10+
help: there is a variant with a similar name
11+
|
12+
LL - println!("My shape is {:?}", Shape::Squareee { size: 5});
13+
LL + println!("My shape is {:?}", Shape::Square { size: 5});
14+
|
915

1016
error[E0599]: no variant named `Circl` found for enum `Shape`
1117
--> $DIR/suggest-variants.rs:13:41
@@ -14,7 +20,13 @@ LL | enum Shape {
1420
| ---------- variant `Circl` not found here
1521
...
1622
LL | println!("My shape is {:?}", Shape::Circl { size: 5});
17-
| ^^^^^ help: there is a variant with a similar name: `Circle`
23+
| ^^^^^
24+
|
25+
help: there is a variant with a similar name
26+
|
27+
LL - println!("My shape is {:?}", Shape::Circl { size: 5});
28+
LL + println!("My shape is {:?}", Shape::Circle { size: 5});
29+
|
1830

1931
error[E0599]: no variant named `Rombus` found for enum `Shape`
2032
--> $DIR/suggest-variants.rs:14:41
@@ -32,10 +44,13 @@ LL | enum Shape {
3244
| ---------- variant or associated item `Squareee` not found for this enum
3345
...
3446
LL | Shape::Squareee;
35-
| ^^^^^^^^
36-
| |
37-
| variant or associated item not found in `Shape`
38-
| help: there is a variant with a similar name: `Square`
47+
| ^^^^^^^^ variant or associated item not found in `Shape`
48+
|
49+
help: there is a variant with a similar name
50+
|
51+
LL - Shape::Squareee;
52+
LL + Shape::Square;
53+
|
3954

4055
error[E0599]: no variant or associated item named `Circl` found for enum `Shape` in the current scope
4156
--> $DIR/suggest-variants.rs:16:12
@@ -44,10 +59,13 @@ LL | enum Shape {
4459
| ---------- variant or associated item `Circl` not found for this enum
4560
...
4661
LL | Shape::Circl;
47-
| ^^^^^
48-
| |
49-
| variant or associated item not found in `Shape`
50-
| help: there is a variant with a similar name: `Circle`
62+
| ^^^^^ variant or associated item not found in `Shape`
63+
|
64+
help: there is a variant with a similar name
65+
|
66+
LL - Shape::Circl;
67+
LL + Shape::Circle;
68+
|
5169

5270
error[E0599]: no variant or associated item named `Rombus` found for enum `Shape` in the current scope
5371
--> $DIR/suggest-variants.rs:17:12

0 commit comments

Comments
 (0)