1 // Regression test for #68641
2 
3 #![feature(generic_associated_types)]
4 
5 trait UnsafeCopy {
6     type Item<'a>: Copy;
7 
copy<'a>(item: &Self::Item<'a>) -> Self::Item<'a>8     fn copy<'a>(item: &Self::Item<'a>) -> Self::Item<'a> {
9         *item
10     }
11 }
12 
13 impl<T> UnsafeCopy for T {
14     type Item<'a> = T;
15     //~^ ERROR the trait bound `T: Copy` is not satisfied
16 }
17 
main()18 fn main() {
19     let mut s = String::from("Hello world!");
20 
21     let copy = String::copy(&s);
22 
23     // Do we indeed point to the samme memory?
24     assert!(s.as_ptr() == copy.as_ptr());
25 
26     // Any use of `copy` is certeinly UB after this
27     drop(s);
28 
29     // UB UB UB UB UB!!
30     println!("{}", copy);
31 }
32