Skip to content

Commit 221b621

Browse files
committed
Add test that multiple impls works with E0223 similar-name suggestion.
1 parent 6702df1 commit 221b621

File tree

2 files changed

+59
-7
lines changed

2 files changed

+59
-7
lines changed

tests/ui/suggestions/issue-109195.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
struct Foo;
2+
3+
impl Foo {
4+
fn bar_baz() {}
5+
}
6+
7+
impl Foo {
8+
fn bar_quux() {}
9+
}
10+
111
fn main() {
212
String::from::utf8;
313
//~^ ERROR ambiguous associated type [E0223]
@@ -17,4 +27,13 @@ fn main() {
1727
str::from::utf8_mut();
1828
//~^ ERROR ambiguous associated type [E0223]
1929
//~| HELP if there were a trait named `Example` with associated type `from`
30+
Foo::bar::baz;
31+
//~^ ERROR ambiguous associated type [E0223]
32+
//~| HELP there is an associated function with a similar name: `bar_baz`
33+
Foo::bar::quux;
34+
//~^ ERROR ambiguous associated type [E0223]
35+
//~| HELP there is an associated function with a similar name: `bar_quux`
36+
Foo::bar::fizz;
37+
//~^ ERROR ambiguous associated type [E0223]
38+
//~| HELP if there were a trait named `Example` with associated type `bar`
2039
}

tests/ui/suggestions/issue-109195.stderr

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0223]: ambiguous associated type
2-
--> $DIR/issue-109195.rs:2:5
2+
--> $DIR/issue-109195.rs:12:5
33
|
44
LL | String::from::utf8;
55
| ^^^^^^^^^^^^
@@ -10,7 +10,7 @@ LL | String::from_utf8;
1010
| ~~~~~~~~~
1111

1212
error[E0223]: ambiguous associated type
13-
--> $DIR/issue-109195.rs:5:5
13+
--> $DIR/issue-109195.rs:15:5
1414
|
1515
LL | String::from::utf8();
1616
| ^^^^^^^^^^^^
@@ -21,7 +21,7 @@ LL | String::from_utf8();
2121
| ~~~~~~~~~
2222

2323
error[E0223]: ambiguous associated type
24-
--> $DIR/issue-109195.rs:8:5
24+
--> $DIR/issue-109195.rs:18:5
2525
|
2626
LL | String::from::utf16();
2727
| ^^^^^^^^^^^^
@@ -32,7 +32,7 @@ LL | String::from_utf16();
3232
| ~~~~~~~~~~
3333

3434
error[E0223]: ambiguous associated type
35-
--> $DIR/issue-109195.rs:11:5
35+
--> $DIR/issue-109195.rs:21:5
3636
|
3737
LL | String::from::method_that_doesnt_exist();
3838
| ^^^^^^^^^^^^
@@ -43,7 +43,7 @@ LL | <String as Example>::from::method_that_doesnt_exist();
4343
| ~~~~~~~~~~~~~~~~~~~~~~~~~
4444

4545
error[E0223]: ambiguous associated type
46-
--> $DIR/issue-109195.rs:14:5
46+
--> $DIR/issue-109195.rs:24:5
4747
|
4848
LL | str::from::utf8();
4949
| ^^^^^^^^^
@@ -54,7 +54,7 @@ LL | <str as Example>::from::utf8();
5454
| ~~~~~~~~~~~~~~~~~~~~~~
5555

5656
error[E0223]: ambiguous associated type
57-
--> $DIR/issue-109195.rs:17:5
57+
--> $DIR/issue-109195.rs:27:5
5858
|
5959
LL | str::from::utf8_mut();
6060
| ^^^^^^^^^
@@ -64,6 +64,39 @@ help: if there were a trait named `Example` with associated type `from` implemen
6464
LL | <str as Example>::from::utf8_mut();
6565
| ~~~~~~~~~~~~~~~~~~~~~~
6666

67-
error: aborting due to 6 previous errors
67+
error[E0223]: ambiguous associated type
68+
--> $DIR/issue-109195.rs:30:5
69+
|
70+
LL | Foo::bar::baz;
71+
| ^^^^^^^^
72+
|
73+
help: there is an associated function with a similar name: `bar_baz`
74+
|
75+
LL | Foo::bar_baz;
76+
| ~~~~~~~
77+
78+
error[E0223]: ambiguous associated type
79+
--> $DIR/issue-109195.rs:33:5
80+
|
81+
LL | Foo::bar::quux;
82+
| ^^^^^^^^
83+
|
84+
help: there is an associated function with a similar name: `bar_quux`
85+
|
86+
LL | Foo::bar_quux;
87+
| ~~~~~~~~
88+
89+
error[E0223]: ambiguous associated type
90+
--> $DIR/issue-109195.rs:36:5
91+
|
92+
LL | Foo::bar::fizz;
93+
| ^^^^^^^^
94+
|
95+
help: if there were a trait named `Example` with associated type `bar` implemented for `Foo`, you could use the fully-qualified path
96+
|
97+
LL | <Foo as Example>::bar::fizz;
98+
| ~~~~~~~~~~~~~~~~~~~~~
99+
100+
error: aborting due to 9 previous errors
68101

69102
For more information about this error, try `rustc --explain E0223`.

0 commit comments

Comments
 (0)