Skip to content

Commit 876e8b0

Browse files
committed
add tests for rust-lang#114061
1 parent fc22045 commit 876e8b0

4 files changed

+86
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Regression test for #114061. We previously did
2+
// not consider `for<'a> <T as WithAssoc<'a>>::Assoc: IsUnit`
3+
// to be unknowable, even though the projection is
4+
// ambiguous.
5+
trait IsUnit {}
6+
impl IsUnit for () {}
7+
8+
9+
pub trait WithAssoc<'a> {
10+
type Assoc;
11+
}
12+
13+
// The two impls of `Trait` overlap
14+
pub trait Trait {}
15+
impl<T> Trait for T
16+
where
17+
T: 'static,
18+
for<'a> T: WithAssoc<'a>,
19+
for<'a> <T as WithAssoc<'a>>::Assoc: IsUnit,
20+
{
21+
}
22+
impl<T> Trait for Box<T> {}
23+
//~^ ERROR conflicting implementations of trait `Trait`
24+
25+
fn main() {}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
error[E0119]: conflicting implementations of trait `Trait` for type `Box<_>`
2+
--> $DIR/ambig-assoc-type-with-bound-vars-1.rs:22:1
3+
|
4+
LL | / impl<T> Trait for T
5+
LL | | where
6+
LL | | T: 'static,
7+
LL | | for<'a> T: WithAssoc<'a>,
8+
LL | | for<'a> <T as WithAssoc<'a>>::Assoc: IsUnit,
9+
| |________________________________________________- first implementation here
10+
...
11+
LL | impl<T> Trait for Box<T> {}
12+
| ^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Box<_>`
13+
|
14+
= note: downstream crates may implement trait `WithAssoc<'a>` for type `std::boxed::Box<_>`
15+
16+
error: aborting due to 1 previous error
17+
18+
For more information about this error, try `rustc --explain E0119`.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Another regression test for #114061.
2+
3+
pub trait WhereBound {}
4+
impl WhereBound for () {}
5+
6+
pub trait WithAssoc<'a> {
7+
type Assoc;
8+
}
9+
10+
// The two impls of `Trait` overlap
11+
pub trait Trait {}
12+
impl<T> Trait for T
13+
where
14+
T: 'static,
15+
for<'a> T: WithAssoc<'a>,
16+
// This bound was previously treated as knowable
17+
for<'a> Box<<T as WithAssoc<'a>>::Assoc>: WhereBound,
18+
{
19+
}
20+
impl<T> Trait for Box<T> {}
21+
//~^ ERROR conflicting implementations of trait `Trait`
22+
23+
fn main() {}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error[E0119]: conflicting implementations of trait `Trait` for type `Box<_>`
2+
--> $DIR/ambig-assoc-type-with-bound-vars-2.rs:20:1
3+
|
4+
LL | / impl<T> Trait for T
5+
LL | | where
6+
LL | | T: 'static,
7+
LL | | for<'a> T: WithAssoc<'a>,
8+
LL | | // This bound was previously treated as knowable
9+
LL | | for<'a> Box<<T as WithAssoc<'a>>::Assoc>: WhereBound,
10+
| |_________________________________________________________- first implementation here
11+
...
12+
LL | impl<T> Trait for Box<T> {}
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Box<_>`
14+
|
15+
= note: downstream crates may implement trait `WithAssoc<'a>` for type `std::boxed::Box<_>`
16+
= note: downstream crates may implement trait `WhereBound` for type `std::boxed::Box<<std::boxed::Box<_> as WithAssoc<'a>>::Assoc>`
17+
18+
error: aborting due to 1 previous error
19+
20+
For more information about this error, try `rustc --explain E0119`.

0 commit comments

Comments
 (0)