Skip to content

Commit 232d685

Browse files
committed
add known-bug test for unsound issue 57893
1 parent 2fb2098 commit 232d685

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// check-pass
2+
// known-bug: #57893
3+
4+
// Should fail. Because we see an impl that uses a certain associated type, we
5+
// type-check assuming that impl is used. However, this conflicts with the
6+
// "implicit impl" that we get for trait objects, violating coherence.
7+
8+
trait Object<U> {
9+
type Output;
10+
}
11+
12+
impl<T: ?Sized, U> Object<U> for T {
13+
type Output = U;
14+
}
15+
16+
fn foo<T: ?Sized, U>(x: <T as Object<U>>::Output) -> U {
17+
x
18+
}
19+
20+
#[allow(dead_code)]
21+
fn transmute<T, U>(x: T) -> U {
22+
foo::<dyn Object<U, Output = T>, U>(x)
23+
}
24+
25+
fn main() {}

0 commit comments

Comments
 (0)