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