Skip to content

Commit e1e4da2

Browse files
committed
Make confusable suggestions verbose
1 parent 385eea1 commit e1e4da2

File tree

14 files changed

+126
-43
lines changed

14 files changed

+126
-43
lines changed

compiler/rustc_hir_typeck/src/method/suggest.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,7 +1375,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13751375
{
13761376
// We found a method with the same number of arguments as the method
13771377
// call expression the user wrote.
1378-
err.span_suggestion(
1378+
err.span_suggestion_verbose(
13791379
span,
13801380
format!("there is {an} method with a similar name"),
13811381
similar_candidate.name,
@@ -1402,7 +1402,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14021402
{
14031403
// We have fn call expression and the argument count match the associated
14041404
// function we found.
1405-
err.span_suggestion(
1405+
err.span_suggestion_verbose(
14061406
span,
14071407
format!(
14081408
"there is {an} {} with a similar name",
@@ -1423,7 +1423,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14231423
}
14241424
} else if let Mode::Path = mode {
14251425
// We have an associated item syntax and we found something that isn't an fn.
1426-
err.span_suggestion(
1426+
err.span_suggestion_verbose(
14271427
span,
14281428
format!(
14291429
"there is {an} {} with a similar name",

tests/ui/associated-item/associated-item-enum.stderr

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ LL | enum Enum { Variant }
55
| --------- variant or associated item `mispellable` not found for this enum
66
...
77
LL | Enum::mispellable();
8-
| ^^^^^^^^^^^
9-
| |
10-
| variant or associated item not found in `Enum`
11-
| help: there is an associated function with a similar name: `misspellable`
8+
| ^^^^^^^^^^^ variant or associated item not found in `Enum`
9+
|
10+
help: there is an associated function with a similar name
11+
|
12+
LL | Enum::misspellable();
13+
| ~~~~~~~~~~~~
1214

1315
error[E0599]: no variant or associated item named `mispellable_trait` found for enum `Enum` in the current scope
1416
--> $DIR/associated-item-enum.rs:18:11
@@ -17,10 +19,12 @@ LL | enum Enum { Variant }
1719
| --------- variant or associated item `mispellable_trait` not found for this enum
1820
...
1921
LL | Enum::mispellable_trait();
20-
| ^^^^^^^^^^^^^^^^^
21-
| |
22-
| variant or associated item not found in `Enum`
23-
| help: there is an associated function with a similar name: `misspellable_trait`
22+
| ^^^^^^^^^^^^^^^^^ variant or associated item not found in `Enum`
23+
|
24+
help: there is an associated function with a similar name
25+
|
26+
LL | Enum::misspellable_trait();
27+
| ~~~~~~~~~~~~~~~~~~
2428

2529
error[E0599]: no variant or associated item named `MISPELLABLE` found for enum `Enum` in the current scope
2630
--> $DIR/associated-item-enum.rs:19:11
@@ -29,10 +33,12 @@ LL | enum Enum { Variant }
2933
| --------- variant or associated item `MISPELLABLE` not found for this enum
3034
...
3135
LL | Enum::MISPELLABLE;
32-
| ^^^^^^^^^^^
33-
| |
34-
| variant or associated item not found in `Enum`
35-
| help: there is an associated constant with a similar name: `MISSPELLABLE`
36+
| ^^^^^^^^^^^ variant or associated item not found in `Enum`
37+
|
38+
help: there is an associated constant with a similar name
39+
|
40+
LL | Enum::MISSPELLABLE;
41+
| ~~~~~~~~~~~~
3642

3743
error: aborting due to 3 previous errors
3844

tests/ui/attributes/rustc_confusables.stderr

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ error[E0599]: no method named `inser` found for struct `rustc_confusables_across
3131
--> $DIR/rustc_confusables.rs:12:7
3232
|
3333
LL | x.inser();
34-
| ^^^^^ help: there is a method with a similar name: `insert`
34+
| ^^^^^
35+
|
36+
help: there is a method with a similar name
37+
|
38+
LL | x.insert();
39+
| ~~~~~~
3540

3641
error[E0599]: no method named `foo` found for struct `rustc_confusables_across_crate::BTreeSet` in the current scope
3742
--> $DIR/rustc_confusables.rs:15:7

tests/ui/block-result/issue-3563.stderr

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ error[E0599]: no method named `b` found for reference `&Self` in the current sco
22
--> $DIR/issue-3563.rs:3:17
33
|
44
LL | || self.b()
5-
| ^ help: there is a method with a similar name: `a`
5+
| ^
6+
|
7+
help: there is a method with a similar name
8+
|
9+
LL | || self.a()
10+
| ~
611

712
error: aborting due to 1 previous error
813

tests/ui/methods/issues/issue-105732.stderr

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ error[E0599]: no method named `g` found for reference `&Self` in the current sco
1010
--> $DIR/issue-105732.rs:10:14
1111
|
1212
LL | self.g();
13-
| ^ help: there is a method with a similar name: `f`
13+
| ^
14+
|
15+
help: there is a method with a similar name
16+
|
17+
LL | self.f();
18+
| ~
1419

1520
error: aborting due to 2 previous errors
1621

tests/ui/methods/method-not-found-but-doc-alias.stderr

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ LL | struct Foo;
55
| ---------- method `quux` not found for this struct
66
...
77
LL | Foo.quux();
8-
| ^^^^ help: there is a method with a similar name: `bar`
8+
| ^^^^
9+
|
10+
help: there is a method with a similar name
11+
|
12+
LL | Foo.bar();
13+
| ~~~
914

1015
error: aborting due to 1 previous error
1116

tests/ui/object-pointer-types.stderr

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ LL | fn owned(self: Box<Self>);
55
| --------- the method might not be found because of this arbitrary self type
66
...
77
LL | x.owned();
8-
| ^^^^^ help: there is a method with a similar name: `to_owned`
8+
| ^^^^^
9+
|
10+
help: there is a method with a similar name
11+
|
12+
LL | x.to_owned();
13+
| ~~~~~~~~
914

1015
error[E0599]: no method named `owned` found for mutable reference `&mut dyn Foo` in the current scope
1116
--> $DIR/object-pointer-types.rs:17:7

tests/ui/parser/emoji-identifiers.stderr

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,17 @@ LL | struct 👀;
7171
| --------- function or associated item `full_of✨` not found for this struct
7272
...
7373
LL | 👀::full_of✨()
74-
| ^^^^^^^^^
75-
| |
76-
| function or associated item not found in `👀`
77-
| help: there is an associated function with a similar name: `full_of_✨`
74+
| ^^^^^^^^^ function or associated item not found in `👀`
7875
|
7976
note: if you're trying to build a new `👀`, consider using `👀::full_of_✨` which returns `👀`
8077
--> $DIR/emoji-identifiers.rs:4:5
8178
|
8279
LL | fn full_of_✨() -> 👀 {
8380
| ^^^^^^^^^^^^^^^^^^^^^
81+
help: there is an associated function with a similar name
82+
|
83+
LL | 👀::full_of_✨()
84+
| ~~~~~~~~~~
8485

8586
error[E0425]: cannot find function `i_like_to_😄_a_lot` in this scope
8687
--> $DIR/emoji-identifiers.rs:13:13

tests/ui/resolve/typo-suggestion-mistyped-in-path.stderr

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ LL | struct Struct;
1414
| ------------- function or associated item `fob` not found for this struct
1515
...
1616
LL | Struct::fob();
17-
| ^^^
18-
| |
19-
| function or associated item not found in `Struct`
20-
| help: there is an associated function with a similar name: `foo`
17+
| ^^^ function or associated item not found in `Struct`
18+
|
19+
help: there is an associated function with a similar name
20+
|
21+
LL | Struct::foo();
22+
| ~~~
2123

2224
error[E0433]: failed to resolve: use of undeclared type `Struc`
2325
--> $DIR/typo-suggestion-mistyped-in-path.rs:27:5

tests/ui/rust-2018/trait-import-suggestions.stderr

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ error[E0599]: no method named `baz` found for type `u32` in the current scope
4040
--> $DIR/trait-import-suggestions.rs:29:7
4141
|
4242
LL | x.baz();
43-
| ^^^ help: there is a method with a similar name: `bar`
43+
| ^^^
44+
|
45+
help: there is a method with a similar name
46+
|
47+
LL | x.bar();
48+
| ~~~
4449

4550
error[E0599]: no function or associated item named `from_str` found for type `u32` in the current scope
4651
--> $DIR/trait-import-suggestions.rs:30:18

0 commit comments

Comments
 (0)