Skip to content

Commit cbe9a4b

Browse files
Rollup merge of #154359 - TaKO8Ki:fix-154189-generalize-associated-type-alias, r=Kivooeo
Add regression test for #154189 Fixes #154189
2 parents f85b70f + 08e064a commit cbe9a4b

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Regression test for https://github.com/rust-lang/rust/issues/154189.
2+
#![feature(unboxed_closures)]
3+
4+
trait ToUnit<'a> {
5+
type Unit;
6+
}
7+
8+
impl ToUnit<'_> for *const u32 {
9+
type Unit = ();
10+
}
11+
12+
trait Overlap<T> {}
13+
14+
type Assoc<'a, T> = <*const T as ToUnit<'a>>::Unit;
15+
16+
impl<T> Overlap<T> for T {}
17+
18+
impl<'a, T> Overlap<(&'a (), Assoc<'a, T>)> for T {}
19+
//~^ ERROR the trait bound `*const T: ToUnit<'a>` is not satisfied
20+
//~| ERROR the trait bound `T: Overlap<(&'a (), _)>` is not satisfied
21+
22+
fn main() {}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
error[E0277]: the trait bound `*const T: ToUnit<'a>` is not satisfied
2+
--> $DIR/generalize-associated-type-alias.rs:18:13
3+
|
4+
LL | impl<'a, T> Overlap<(&'a (), Assoc<'a, T>)> for T {}
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `ToUnit<'a>` is not implemented for `*const T`
6+
|
7+
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
8+
|
9+
LL | impl<'a, T> Overlap<(&'a (), Assoc<'a, T>)> for T where *const T: ToUnit<'a> {}
10+
| ++++++++++++++++++++++++++
11+
12+
error[E0277]: the trait bound `T: Overlap<(&'a (), _)>` is not satisfied
13+
--> $DIR/generalize-associated-type-alias.rs:18:49
14+
|
15+
LL | impl<'a, T> Overlap<(&'a (), Assoc<'a, T>)> for T {}
16+
| ^ the trait `Overlap<(&'a (), _)>` is not implemented for `T`
17+
|
18+
help: the trait `Overlap<(&'a (), _)>` is not implemented for `T`
19+
but trait `Overlap<(&(), ())>` is implemented for `u32`
20+
--> $DIR/generalize-associated-type-alias.rs:18:1
21+
|
22+
LL | impl<'a, T> Overlap<(&'a (), Assoc<'a, T>)> for T {}
23+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
24+
= help: for that trait implementation, expected `u32`, found `T`
25+
26+
error: aborting due to 2 previous errors
27+
28+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)