Skip to content

Commit ea206f2

Browse files
committed
Add compile fail test for issue 27675
1 parent deec530 commit ea206f2

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/// The compiler previously did not properly check the bound of `From` when it was used from type
2+
/// of the dyn trait object (use in `copy_any` below). Since the associated type is under user
3+
/// control in this usage, the compiler could be tricked to believe any type implemented any trait.
4+
/// This would ICE, except for pure marker traits like `Copy`. It did not require providing an
5+
/// instance of the dyn trait type, only name said type.
6+
trait Setup {
7+
type From: Copy;
8+
}
9+
10+
fn copy<U: Setup + ?Sized>(from: &U::From) -> U::From {
11+
*from
12+
}
13+
14+
pub fn copy_any<T>(t: &T) -> T {
15+
copy::<dyn Setup<From=T>>(t)
16+
//~^ ERROR the trait bound `T: Copy` is not satisfied
17+
}
18+
19+
fn main() {}

0 commit comments

Comments
 (0)