]> git.lizzy.rs Git - rust.git/blob - src/test/ui/coherence/deep-bad-copy-reason.rs
Auto merge of #91030 - estebank:trait-bounds-are-tricky-2, r=oli-obk
[rust.git] / src / test / ui / coherence / deep-bad-copy-reason.rs
1 #![feature(extern_types)]
2
3 extern "Rust" {
4     type OpaqueListContents;
5 }
6
7 pub struct ListS<T> {
8     len: usize,
9     data: [T; 0],
10     opaque: OpaqueListContents,
11 }
12
13 pub struct Interned<'a, T>(&'a T);
14
15 impl<'a, T> Clone for Interned<'a, T> {
16     fn clone(&self) -> Self {
17         *self
18     }
19 }
20
21 impl<'a, T> Copy for Interned<'a, T> {}
22
23 pub struct List<'tcx, T>(Interned<'tcx, ListS<T>>);
24 //~^ NOTE this field does not implement `Copy`
25 //~| NOTE the `Copy` impl for `Interned<'tcx, ListS<T>>` requires that `OpaqueListContents: Sized`
26
27 impl<'tcx, T> Clone for List<'tcx, T> {
28     fn clone(&self) -> Self {
29         *self
30     }
31 }
32
33 impl<'tcx, T> Copy for List<'tcx, T> {}
34 //~^ ERROR the trait `Copy` may not be implemented for this type
35
36 fn assert_is_copy<T: Copy>() {}
37
38 fn main() {
39     assert_is_copy::<List<'static, ()>>();
40 }