forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
4 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
tests/ui/coherence/aliases/ambig-assoc-type-with-bound-vars-1.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,25 @@ | ||
// Regression test for #114061. We previously did | ||
// not consider `for<'a> <T as WithAssoc<'a>>::Assoc: IsUnit` | ||
// to be unknowable, even though the projection is | ||
// ambiguous. | ||
trait IsUnit {} | ||
impl IsUnit for () {} | ||
|
||
|
||
pub trait WithAssoc<'a> { | ||
type Assoc; | ||
} | ||
|
||
// The two impls of `Trait` overlap | ||
pub trait Trait {} | ||
impl<T> Trait for T | ||
where | ||
T: 'static, | ||
for<'a> T: WithAssoc<'a>, | ||
for<'a> <T as WithAssoc<'a>>::Assoc: IsUnit, | ||
{ | ||
} | ||
impl<T> Trait for Box<T> {} | ||
//~^ ERROR conflicting implementations of trait `Trait` | ||
|
||
fn main() {} |
18 changes: 18 additions & 0 deletions
18
tests/ui/coherence/aliases/ambig-assoc-type-with-bound-vars-1.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,18 @@ | ||
error[E0119]: conflicting implementations of trait `Trait` for type `Box<_>` | ||
--> $DIR/ambig-assoc-type-with-bound-vars-1.rs:22:1 | ||
| | ||
LL | / impl<T> Trait for T | ||
LL | | where | ||
LL | | T: 'static, | ||
LL | | for<'a> T: WithAssoc<'a>, | ||
LL | | for<'a> <T as WithAssoc<'a>>::Assoc: IsUnit, | ||
| |________________________________________________- first implementation here | ||
... | ||
LL | impl<T> Trait for Box<T> {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Box<_>` | ||
| | ||
= note: downstream crates may implement trait `WithAssoc<'a>` for type `std::boxed::Box<_>` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0119`. |
23 changes: 23 additions & 0 deletions
23
tests/ui/coherence/aliases/ambig-assoc-type-with-bound-vars-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,23 @@ | ||
// Another regression test for #114061. | ||
|
||
pub trait WhereBound {} | ||
impl WhereBound for () {} | ||
|
||
pub trait WithAssoc<'a> { | ||
type Assoc; | ||
} | ||
|
||
// The two impls of `Trait` overlap | ||
pub trait Trait {} | ||
impl<T> Trait for T | ||
where | ||
T: 'static, | ||
for<'a> T: WithAssoc<'a>, | ||
// This bound was previously treated as knowable | ||
for<'a> Box<<T as WithAssoc<'a>>::Assoc>: WhereBound, | ||
{ | ||
} | ||
impl<T> Trait for Box<T> {} | ||
//~^ ERROR conflicting implementations of trait `Trait` | ||
|
||
fn main() {} |
20 changes: 20 additions & 0 deletions
20
tests/ui/coherence/aliases/ambig-assoc-type-with-bound-vars-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,20 @@ | ||
error[E0119]: conflicting implementations of trait `Trait` for type `Box<_>` | ||
--> $DIR/ambig-assoc-type-with-bound-vars-2.rs:20:1 | ||
| | ||
LL | / impl<T> Trait for T | ||
LL | | where | ||
LL | | T: 'static, | ||
LL | | for<'a> T: WithAssoc<'a>, | ||
LL | | // This bound was previously treated as knowable | ||
LL | | for<'a> Box<<T as WithAssoc<'a>>::Assoc>: WhereBound, | ||
| |_________________________________________________________- first implementation here | ||
... | ||
LL | impl<T> Trait for Box<T> {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Box<_>` | ||
| | ||
= note: downstream crates may implement trait `WithAssoc<'a>` for type `std::boxed::Box<_>` | ||
= note: downstream crates may implement trait `WhereBound` for type `std::boxed::Box<<std::boxed::Box<_> as WithAssoc<'a>>::Assoc>` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0119`. |