• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: Apache-2.0 OR MIT
2 
3 // Note: If you change this test, change 'trivial_bounds.rs' at the same time.
4 
5 mod phantom_pinned {
6     use std::marker::{PhantomData, PhantomPinned};
7 
8     struct A(PhantomPinned);
9 
10     impl Unpin for A where PhantomPinned: Unpin {} //~ ERROR E0277
11 
12     struct Wrapper<T>(T);
13 
14     impl<T> Unpin for Wrapper<T> where T: Unpin {}
15 
16     struct B(PhantomPinned);
17 
18     impl Unpin for B where Wrapper<PhantomPinned>: Unpin {} //~ ERROR E0277
19 
20     struct WrapperWithLifetime<'a, T>(PhantomData<&'a ()>, T);
21 
22     impl<T> Unpin for WrapperWithLifetime<'_, T> where T: Unpin {}
23 
24     struct C(PhantomPinned);
25 
26     impl<'a> Unpin for C where WrapperWithLifetime<'a, PhantomPinned>: Unpin {} // Ok
27 }
28 
29 mod inner {
30     use std::marker::{PhantomData, PhantomPinned};
31 
32     struct Inner(PhantomPinned);
33 
34     struct A(Inner);
35 
36     impl Unpin for A where Inner: Unpin {} //~ ERROR E0277
37 
38     struct Wrapper<T>(T);
39 
40     impl<T> Unpin for Wrapper<T> where T: Unpin {}
41 
42     struct B(Inner);
43 
44     impl Unpin for B where Wrapper<Inner>: Unpin {} //~ ERROR E0277
45 
46     struct WrapperWithLifetime<'a, T>(PhantomData<&'a ()>, T);
47 
48     impl<T> Unpin for WrapperWithLifetime<'_, T> where T: Unpin {}
49 
50     struct C(Inner);
51 
52     impl<'a> Unpin for C where WrapperWithLifetime<'a, Inner>: Unpin {} // Ok
53 }
54 
main()55 fn main() {}
56