-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2c43098
commit b1b8aeb
Showing
10 changed files
with
245 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//@ run-pass | ||
//@ check-run-results | ||
|
||
#![feature(supertrait_item_shadowing)] | ||
#![allow(dead_code)] | ||
|
||
trait A { | ||
fn hello(&self) { | ||
println!("A"); | ||
} | ||
} | ||
impl<T> A for T {} | ||
|
||
trait B: A { | ||
fn hello(&self) { | ||
println!("B"); | ||
} | ||
} | ||
impl<T> B for T {} | ||
|
||
fn main() { | ||
().hello(); | ||
//~^ WARN trait method `hello` from `B` shadows identically named method from supertrait | ||
} |
1 change: 1 addition & 0 deletions
1
tests/ui/methods/supertrait-shadowing/common-ancestor.run.stdout
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 @@ | ||
B |
20 changes: 20 additions & 0 deletions
20
tests/ui/methods/supertrait-shadowing/common-ancestor.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,20 @@ | ||
warning: trait method `hello` from `B` shadows identically named method from supertrait | ||
--> $DIR/common-ancestor.rs:22:8 | ||
| | ||
LL | ().hello(); | ||
| ^^^^^ | ||
| | ||
note: method from `B` shadows a supertrait method | ||
--> $DIR/common-ancestor.rs:15:5 | ||
| | ||
LL | fn hello(&self) { | ||
| ^^^^^^^^^^^^^^^ | ||
note: method from `A` is shadowed by a subtrait method | ||
--> $DIR/common-ancestor.rs:8:5 | ||
| | ||
LL | fn hello(&self) { | ||
| ^^^^^^^^^^^^^^^ | ||
= note: `#[warn(supertrait_item_shadowing)]` on by default | ||
|
||
warning: 1 warning emitted | ||
|
20 changes: 20 additions & 0 deletions
20
tests/ui/methods/supertrait-shadowing/no-common-ancestor.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,20 @@ | ||
#![feature(supertrait_item_shadowing)] | ||
|
||
trait A { | ||
fn hello(&self) { | ||
println!("A"); | ||
} | ||
} | ||
impl<T> A for T {} | ||
|
||
trait B { | ||
fn hello(&self) { | ||
println!("B"); | ||
} | ||
} | ||
impl<T> B for T {} | ||
|
||
fn main() { | ||
().hello(); | ||
//~^ ERROR multiple applicable items in scope | ||
} |
28 changes: 28 additions & 0 deletions
28
tests/ui/methods/supertrait-shadowing/no-common-ancestor.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,28 @@ | ||
error[E0034]: multiple applicable items in scope | ||
--> $DIR/no-common-ancestor.rs:18:8 | ||
| | ||
LL | ().hello(); | ||
| ^^^^^ multiple `hello` found | ||
| | ||
note: candidate #1 is defined in an impl of the trait `A` for the type `T` | ||
--> $DIR/no-common-ancestor.rs:4:5 | ||
| | ||
LL | fn hello(&self) { | ||
| ^^^^^^^^^^^^^^^ | ||
note: candidate #2 is defined in an impl of the trait `B` for the type `T` | ||
--> $DIR/no-common-ancestor.rs:11:5 | ||
| | ||
LL | fn hello(&self) { | ||
| ^^^^^^^^^^^^^^^ | ||
help: disambiguate the method for candidate #1 | ||
| | ||
LL | A::hello(&()); | ||
| ~~~~~~~~~~~~~ | ||
help: disambiguate the method for candidate #2 | ||
| | ||
LL | B::hello(&()); | ||
| ~~~~~~~~~~~~~ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0034`. |