forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#62921 - iluuu1994:improve-help-for-method-d…
…isambiguation, r=estebank Add method disambiguation help for trait implementation Closes rust-lang#51046 Closes rust-lang#40471
- Loading branch information
Showing
13 changed files
with
123 additions
and
19 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
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
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
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,16 @@ | ||
trait A { fn foo(self); } | ||
trait B { fn foo(self); } | ||
|
||
struct AB {} | ||
|
||
impl A for AB { | ||
fn foo(self) {} | ||
} | ||
|
||
impl B for AB { | ||
fn foo(self) {} | ||
} | ||
|
||
fn main() { | ||
AB {}.foo(); //~ ERROR E0034 | ||
} |
22 changes: 22 additions & 0 deletions
22
src/test/ui/methods/method-ambig-two-traits-from-impls.stderr
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,22 @@ | ||
error[E0034]: multiple applicable items in scope | ||
--> $DIR/method-ambig-two-traits-from-impls.rs:15:11 | ||
| | ||
LL | AB {}.foo(); | ||
| ^^^ multiple `foo` found | ||
| | ||
note: candidate #1 is defined in an impl of the trait `A` for the type `AB` | ||
--> $DIR/method-ambig-two-traits-from-impls.rs:7:5 | ||
| | ||
LL | fn foo(self) {} | ||
| ^^^^^^^^^^^^ | ||
= help: to disambiguate the method call, write `A::foo(AB {})` instead | ||
note: candidate #2 is defined in an impl of the trait `B` for the type `AB` | ||
--> $DIR/method-ambig-two-traits-from-impls.rs:11:5 | ||
| | ||
LL | fn foo(self) {} | ||
| ^^^^^^^^^^^^ | ||
= help: to disambiguate the method call, write `B::foo(AB {})` instead | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0034`. |
16 changes: 16 additions & 0 deletions
16
src/test/ui/methods/method-ambig-two-traits-from-impls2.rs
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,16 @@ | ||
trait A { fn foo(); } | ||
trait B { fn foo(); } | ||
|
||
struct AB {} | ||
|
||
impl A for AB { | ||
fn foo() {} | ||
} | ||
|
||
impl B for AB { | ||
fn foo() {} | ||
} | ||
|
||
fn main() { | ||
AB::foo(); //~ ERROR E0034 | ||
} |
22 changes: 22 additions & 0 deletions
22
src/test/ui/methods/method-ambig-two-traits-from-impls2.stderr
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,22 @@ | ||
error[E0034]: multiple applicable items in scope | ||
--> $DIR/method-ambig-two-traits-from-impls2.rs:15:5 | ||
| | ||
LL | AB::foo(); | ||
| ^^^^^^^ multiple `foo` found | ||
| | ||
note: candidate #1 is defined in an impl of the trait `A` for the type `AB` | ||
--> $DIR/method-ambig-two-traits-from-impls2.rs:7:5 | ||
| | ||
LL | fn foo() {} | ||
| ^^^^^^^^ | ||
= help: to disambiguate the method call, write `A::foo(...)` instead | ||
note: candidate #2 is defined in an impl of the trait `B` for the type `AB` | ||
--> $DIR/method-ambig-two-traits-from-impls2.rs:11:5 | ||
| | ||
LL | fn foo() {} | ||
| ^^^^^^^^ | ||
= help: to disambiguate the method call, write `B::foo(...)` instead | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0034`. |
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
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