We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent deec530 commit ea206f2Copy full SHA for ea206f2
src/test/compile-fail/issue-27675-unchecked-bounds.rs
@@ -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