]> git.lizzy.rs Git - rust.git/blob - src/test/ui/generic-associated-types/issue-74824.rs
Auto merge of #99612 - yanchen4791:issue-95079-fix, r=compiler-errors
[rust.git] / src / test / ui / generic-associated-types / issue-74824.rs
1 #![feature(generic_associated_types)]
2 #![feature(associated_type_defaults)]
3
4 use std::ops::Deref;
5
6 trait UnsafeCopy {
7     type Copy<T>: Copy = Box<T>;
8     //~^ ERROR the trait bound `Box<T>: Copy` is not satisfied
9     //~^^ ERROR the trait bound `T: Clone` is not satisfied
10     fn copy<T>(x: &Self::Copy<T>) -> Self::Copy<T> {
11         *x
12     }
13 }
14
15 impl<T> UnsafeCopy for T {}
16
17 fn main() {
18     let b = Box::new(42usize);
19     let copy = <()>::copy(&b);
20
21     let raw_b = Box::deref(&b) as *const _;
22     let raw_copy = Box::deref(&copy) as *const _;
23
24     // assert the addresses.
25     assert_eq!(raw_b, raw_copy);
26 }