-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Check uniqueness of impl items by trait item when applicable. #100387
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 all commits
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
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
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
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 |
---|---|---|
|
@@ -16,4 +16,5 @@ impl Foo for Baz { | |
|
||
fn main() { | ||
let x: Baz::Bar = 5; | ||
//~^ ERROR ambiguous associated type | ||
} |
18 changes: 14 additions & 4 deletions
18
src/test/ui/associated-item/associated-item-duplicate-names-3.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 |
---|---|---|
@@ -1,11 +1,21 @@ | ||
error[E0201]: duplicate definitions with name `Bar`: | ||
--> $DIR/associated-item-duplicate-names-3.rs:14:5 | ||
| | ||
LL | type Bar; | ||
| --------- item in trait | ||
... | ||
LL | type Bar = i16; | ||
| -------- previous definition of `Bar` here | ||
| --------------- previous definition here | ||
LL | type Bar = u16; | ||
| ^^^^^^^^ duplicate definition | ||
| ^^^^^^^^^^^^^^^ duplicate definition | ||
|
||
error: aborting due to previous error | ||
error[E0223]: ambiguous associated type | ||
--> $DIR/associated-item-duplicate-names-3.rs:18:12 | ||
| | ||
LL | let x: Baz::Bar = 5; | ||
| ^^^^^^^^ help: use fully-qualified syntax: `<Baz as Trait>::Bar` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0201`. | ||
Some errors have detailed explanations: E0201, E0223. | ||
For more information about an error, try `rustc --explain E0201`. |
14 changes: 10 additions & 4 deletions
14
src/test/ui/associated-item/associated-item-duplicate-names.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
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,26 @@ | ||
#![feature(decl_macro)] | ||
|
||
trait Trait { | ||
fn foo() {} | ||
} | ||
|
||
macro trait_impl() { | ||
fn foo() {} | ||
} | ||
|
||
// Check that we error on multiple impl items that resolve to the same trait item. | ||
impl Trait for i32 { | ||
trait_impl!(); | ||
fn foo() {} | ||
//~^ ERROR duplicate definitions with name `foo`: [E0201] | ||
} | ||
|
||
struct Type; | ||
|
||
// Check that we do not error with inherent impls. | ||
impl Type { | ||
trait_impl!(); | ||
fn foo() {} | ||
} | ||
|
||
fn main() {} | ||
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,15 @@ | ||
error[E0201]: duplicate definitions with name `foo`: | ||
--> $DIR/impl_items-2.rs:14:5 | ||
| | ||
LL | fn foo() {} | ||
| ----------- item in trait | ||
... | ||
LL | fn foo() {} | ||
| ----------- previous definition here | ||
... | ||
LL | fn foo() {} | ||
| ^^^^^^^^^^^ duplicate definition | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0201`. |
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
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.