File tree 2 files changed +54
-0
lines changed
src/test/ui/generic-associated-types
2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change
1
+ #![ feature( generic_associated_types) ]
2
+ #![ feature( associated_type_defaults) ]
3
+ #![ allow( incomplete_features) ]
4
+
5
+ use std:: ops:: Deref ;
6
+
7
+ trait UnsafeCopy {
8
+ type Copy < T > : Copy = Box < T > ;
9
+ //~^ ERROR the trait bound `Box<T>: Copy` is not satisfied
10
+ //~^^ ERROR the trait bound `T: Clone` is not satisfied
11
+ fn copy < T > ( x : & Self :: Copy < T > ) -> Self :: Copy < T > {
12
+ * x
13
+ }
14
+ }
15
+
16
+ impl < T > UnsafeCopy for T { }
17
+
18
+ fn main ( ) {
19
+ let b = Box :: new ( 42usize ) ;
20
+ let copy = <( ) >:: copy ( & b) ;
21
+
22
+ let raw_b = Box :: deref ( & b) as * const _ ;
23
+ let raw_copy = Box :: deref ( & copy) as * const _ ;
24
+
25
+ // assert the addresses.
26
+ assert_eq ! ( raw_b, raw_copy) ;
27
+ }
Original file line number Diff line number Diff line change
1
+ error[E0277]: the trait bound `Box<T>: Copy` is not satisfied
2
+ --> $DIR/issue-74824.rs:8:5
3
+ |
4
+ LL | type Copy<T>: Copy = Box<T>;
5
+ | ^^^^^^^^^^^^^^----^^^^^^^^^^
6
+ | | |
7
+ | | required by this bound in `UnsafeCopy::Copy`
8
+ | the trait `Copy` is not implemented for `Box<T>`
9
+
10
+ error[E0277]: the trait bound `T: Clone` is not satisfied
11
+ --> $DIR/issue-74824.rs:8:5
12
+ |
13
+ LL | type Copy<T>: Copy = Box<T>;
14
+ | ^^^^^^^^^^^^^^----^^^^^^^^^^
15
+ | | |
16
+ | | required by this bound in `UnsafeCopy::Copy`
17
+ | the trait `Clone` is not implemented for `T`
18
+ |
19
+ = note: required because of the requirements on the impl of `Clone` for `Box<T>`
20
+ help: consider restricting type parameter `T`
21
+ |
22
+ LL | type Copy<T: Clone>: Copy = Box<T>;
23
+ | ^^^^^^^
24
+
25
+ error: aborting due to 2 previous errors
26
+
27
+ For more information about this error, try `rustc --explain E0277`.
You can’t perform that action at this time.
0 commit comments