-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #117848 - compiler-errors:method-ambiguity-no-rcvr, r=T…
…aKO8Ki Don't expect a rcvr in `print_disambiguation_help` We don't necessarily have a receiver when we are both accidentally using the `.` operator *AND* we have more than one ambiguous method candidate. Fixes #117728
- Loading branch information
Showing
3 changed files
with
52 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
struct Qux; | ||
|
||
trait Foo { | ||
fn foo(); | ||
} | ||
|
||
trait FooBar { | ||
fn foo() {} | ||
} | ||
|
||
fn main() { | ||
Qux.foo(); | ||
//~^ ERROR no method named `foo` found for struct `Qux` in the current scope | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
error[E0599]: no method named `foo` found for struct `Qux` in the current scope | ||
--> $DIR/method-ambiguity-no-rcvr.rs:12:9 | ||
| | ||
LL | struct Qux; | ||
| ---------- method `foo` not found for this struct | ||
... | ||
LL | Qux.foo(); | ||
| ^^^ this is an associated function, not a method | ||
| | ||
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter | ||
note: candidate #1 is defined in the trait `Foo` | ||
--> $DIR/method-ambiguity-no-rcvr.rs:4:5 | ||
| | ||
LL | fn foo(); | ||
| ^^^^^^^^^ | ||
note: candidate #2 is defined in the trait `FooBar` | ||
--> $DIR/method-ambiguity-no-rcvr.rs:8:5 | ||
| | ||
LL | fn foo() {} | ||
| ^^^^^^^^ | ||
help: disambiguate the associated function for candidate #1 | ||
| | ||
LL | <Qux as Foo>::foo(Qux); | ||
| ~~~~~~~~~~~~~~~~~~~~~~ | ||
help: disambiguate the associated function for candidate #2 | ||
| | ||
LL | <Qux as FooBar>::foo(Qux); | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0599`. |