]> git.lizzy.rs Git - rust.git/blob - src/test/ui/generic-associated-types/issue-68641-check-gat-bounds.rs
Merge commit '5ff7b632a95bac6955611d85040859128902c580' into sync-rustfmt-subtree
[rust.git] / src / test / ui / generic-associated-types / issue-68641-check-gat-bounds.rs
1 // Regression test for #68641
2
3 #![feature(generic_associated_types)]
4
5 trait UnsafeCopy {
6     type Item<'a>: Copy;
7
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
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 }