-
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.
Rework collapse method to work correctly with more complex supertrait…
… graphs
- Loading branch information
1 parent
b1b8aeb
commit 069e9d2
Showing
9 changed files
with
251 additions
and
21 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
31 changes: 31 additions & 0 deletions
31
tests/ui/methods/supertrait-shadowing/common-ancestor-2.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,31 @@ | ||
//@ 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 { | ||
fn hello(&self) { | ||
println!("B"); | ||
} | ||
} | ||
impl<T> B for T {} | ||
|
||
trait C: A + B { | ||
fn hello(&self) { | ||
println!("C"); | ||
} | ||
} | ||
impl<T> C for T {} | ||
|
||
fn main() { | ||
().hello(); | ||
//~^ WARN trait method `hello` from `C` shadows identically named method from supertrait | ||
} |
1 change: 1 addition & 0 deletions
1
tests/ui/methods/supertrait-shadowing/common-ancestor-2.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 @@ | ||
C |
23 changes: 23 additions & 0 deletions
23
tests/ui/methods/supertrait-shadowing/common-ancestor-2.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,23 @@ | ||
warning: trait method `hello` from `C` shadows identically named method from supertrait | ||
--> $DIR/common-ancestor-2.rs:29:8 | ||
| | ||
LL | ().hello(); | ||
| ^^^^^ | ||
| | ||
note: method from `C` shadows a supertrait method | ||
--> $DIR/common-ancestor-2.rs:22:5 | ||
| | ||
LL | fn hello(&self) { | ||
| ^^^^^^^^^^^^^^^ | ||
note: methods from several supertraits are shadowed: `A` and `B` | ||
--> $DIR/common-ancestor-2.rs:8:5 | ||
| | ||
LL | fn hello(&self) { | ||
| ^^^^^^^^^^^^^^^ | ||
... | ||
LL | fn hello(&self) { | ||
| ^^^^^^^^^^^^^^^ | ||
= note: `#[warn(supertrait_item_shadowing)]` on by default | ||
|
||
warning: 1 warning emitted | ||
|
40 changes: 40 additions & 0 deletions
40
tests/ui/methods/supertrait-shadowing/common-ancestor-3.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,40 @@ | ||
//@ 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 { | ||
fn hello(&self) { | ||
println!("B"); | ||
} | ||
} | ||
impl<T> B for T {} | ||
|
||
trait C: A + B { | ||
fn hello(&self) { | ||
println!("C"); | ||
} | ||
} | ||
impl<T> C for T {} | ||
|
||
// `D` extends `C` which extends `B` and `A` | ||
|
||
trait D: C { | ||
fn hello(&self) { | ||
println!("D"); | ||
} | ||
} | ||
impl<T> D for T {} | ||
|
||
fn main() { | ||
().hello(); | ||
//~^ WARN trait method `hello` from `D` shadows identically named method from supertrait | ||
} |
1 change: 1 addition & 0 deletions
1
tests/ui/methods/supertrait-shadowing/common-ancestor-3.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 @@ | ||
D |
26 changes: 26 additions & 0 deletions
26
tests/ui/methods/supertrait-shadowing/common-ancestor-3.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,26 @@ | ||
warning: trait method `hello` from `D` shadows identically named method from supertrait | ||
--> $DIR/common-ancestor-3.rs:38:8 | ||
| | ||
LL | ().hello(); | ||
| ^^^^^ | ||
| | ||
note: method from `D` shadows a supertrait method | ||
--> $DIR/common-ancestor-3.rs:31:5 | ||
| | ||
LL | fn hello(&self) { | ||
| ^^^^^^^^^^^^^^^ | ||
note: methods from several supertraits are shadowed: `A`, `B`, and `C` | ||
--> $DIR/common-ancestor-3.rs:8:5 | ||
| | ||
LL | fn hello(&self) { | ||
| ^^^^^^^^^^^^^^^ | ||
... | ||
LL | fn hello(&self) { | ||
| ^^^^^^^^^^^^^^^ | ||
... | ||
LL | fn hello(&self) { | ||
| ^^^^^^^^^^^^^^^ | ||
= note: `#[warn(supertrait_item_shadowing)]` on by default | ||
|
||
warning: 1 warning emitted | ||
|
37 changes: 37 additions & 0 deletions
37
tests/ui/methods/supertrait-shadowing/no-common-ancestor-2.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,37 @@ | ||
#![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 {} | ||
|
||
trait C: A + B { | ||
fn hello(&self) { | ||
println!("C"); | ||
} | ||
} | ||
impl<T> C for T {} | ||
|
||
// Since `D` is not a subtrait of `C`, | ||
// we have no obvious lower bound. | ||
|
||
trait D: B { | ||
fn hello(&self) { | ||
println!("D"); | ||
} | ||
} | ||
impl<T> D for T {} | ||
|
||
fn main() { | ||
().hello(); | ||
//~^ ERROR multiple applicable items in scope | ||
} |
46 changes: 46 additions & 0 deletions
46
tests/ui/methods/supertrait-shadowing/no-common-ancestor-2.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,46 @@ | ||
error[E0034]: multiple applicable items in scope | ||
--> $DIR/no-common-ancestor-2.rs:35: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-2.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-2.rs:11:5 | ||
| | ||
LL | fn hello(&self) { | ||
| ^^^^^^^^^^^^^^^ | ||
note: candidate #3 is defined in an impl of the trait `C` for the type `T` | ||
--> $DIR/no-common-ancestor-2.rs:18:5 | ||
| | ||
LL | fn hello(&self) { | ||
| ^^^^^^^^^^^^^^^ | ||
note: candidate #4 is defined in an impl of the trait `D` for the type `T` | ||
--> $DIR/no-common-ancestor-2.rs:28: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(&()); | ||
| ~~~~~~~~~~~~~ | ||
help: disambiguate the method for candidate #3 | ||
| | ||
LL | C::hello(&()); | ||
| ~~~~~~~~~~~~~ | ||
help: disambiguate the method for candidate #4 | ||
| | ||
LL | D::hello(&()); | ||
| ~~~~~~~~~~~~~ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0034`. |