-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Properly account for self ty in method disambiguation suggestion #116713
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Properly account for self ty in method disambiguation suggestion
Fix #116703.
- Loading branch information
commit 5cc9216ff3552ac1f6b545860bc25f25cf6551df
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,27 @@ | ||
| trait A { | ||
| fn foo(&self); | ||
| } | ||
|
|
||
| trait B { | ||
| fn foo(&self); | ||
| } | ||
|
|
||
| #[derive(Debug)] | ||
| struct S; | ||
|
|
||
| impl<T: std::fmt::Debug> A for T { | ||
| fn foo(&self) {} //~ NOTE candidate #1 | ||
| } | ||
|
|
||
| impl<T: std::fmt::Debug> B for T { | ||
| fn foo(&self) {} //~ NOTE candidate #2 | ||
| } | ||
|
|
||
| fn main() { | ||
| let s = S; | ||
| S::foo(&s); //~ ERROR multiple applicable items in scope | ||
| //~^ NOTE multiple `foo` found | ||
| //~| HELP disambiguate | ||
| //~| HELP disambiguate | ||
| } | ||
|
|
28 changes: 28 additions & 0 deletions
28
tests/ui/methods/disambiguate-multiple-blanket-impl.stderr
This file contains hidden or 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,28 @@ | ||
| error[E0034]: multiple applicable items in scope | ||
| --> $DIR/disambiguate-multiple-blanket-impl.rs:22:8 | ||
| | | ||
| LL | S::foo(&s); | ||
| | ^^^ multiple `foo` found | ||
| | | ||
| note: candidate #1 is defined in an impl of the trait `A` for the type `T` | ||
| --> $DIR/disambiguate-multiple-blanket-impl.rs:13:5 | ||
| | | ||
| LL | fn foo(&self) {} | ||
| | ^^^^^^^^^^^^^ | ||
| note: candidate #2 is defined in an impl of the trait `B` for the type `T` | ||
| --> $DIR/disambiguate-multiple-blanket-impl.rs:17:5 | ||
| | | ||
| LL | fn foo(&self) {} | ||
| | ^^^^^^^^^^^^^ | ||
| help: disambiguate the method for candidate #1 | ||
| | | ||
| LL | <T as A>::foo(&s); | ||
| | ~~~~~~~~~~ | ||
| help: disambiguate the method for candidate #2 | ||
| | | ||
| LL | <T as B>::foo(&s); | ||
| | ~~~~~~~~~~ | ||
|
|
||
| error: aborting due to previous error | ||
|
|
||
| For more information about this error, try `rustc --explain E0034`. |
This file contains hidden or 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,26 @@ | ||
| trait A { | ||
| fn foo(&self); | ||
| } | ||
|
|
||
| trait B { | ||
| fn foo(&self); | ||
| } | ||
|
|
||
| struct S; | ||
|
|
||
| impl A for S { | ||
| fn foo(&self) {} //~ NOTE candidate #1 | ||
| } | ||
|
|
||
| impl B for S { | ||
| fn foo(&self) {} //~ NOTE candidate #2 | ||
| } | ||
|
|
||
| fn main() { | ||
| let s = S; | ||
| S::foo(&s); //~ ERROR multiple applicable items in scope | ||
| //~^ NOTE multiple `foo` found | ||
| //~| HELP disambiguate | ||
| //~| HELP disambiguate | ||
| } | ||
|
|
This file contains hidden or 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,28 @@ | ||
| error[E0034]: multiple applicable items in scope | ||
| --> $DIR/disambiguate-multiple-impl.rs:21:8 | ||
| | | ||
| LL | S::foo(&s); | ||
| | ^^^ multiple `foo` found | ||
| | | ||
| note: candidate #1 is defined in an impl of the trait `A` for the type `S` | ||
| --> $DIR/disambiguate-multiple-impl.rs:12:5 | ||
| | | ||
| LL | fn foo(&self) {} | ||
| | ^^^^^^^^^^^^^ | ||
| note: candidate #2 is defined in an impl of the trait `B` for the type `S` | ||
| --> $DIR/disambiguate-multiple-impl.rs:16:5 | ||
| | | ||
| LL | fn foo(&self) {} | ||
| | ^^^^^^^^^^^^^ | ||
| help: disambiguate the method for candidate #1 | ||
| | | ||
| LL | <S as A>::foo(&s); | ||
| | ~~~~~~~~~~ | ||
| help: disambiguate the method for candidate #2 | ||
| | | ||
| LL | <S as B>::foo(&s); | ||
| | ~~~~~~~~~~ | ||
|
|
||
| error: aborting due to previous error | ||
|
|
||
| For more information about this error, try `rustc --explain E0034`. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.