-
-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathtrivial_bounds-feature-gate.rs
52 lines (29 loc) · 1.23 KB
/
trivial_bounds-feature-gate.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// NB: If you change this test, change 'trivial_bounds.rs' at the same time.
use std::marker::{PhantomData, PhantomPinned};
fn phantom_pinned() {
struct Foo(PhantomPinned);
impl Unpin for Foo where PhantomPinned: Unpin {} //~ ERROR E0277
struct Wrapper<T>(T);
impl<T> Unpin for Wrapper<T> where T: Unpin {}
struct Bar(PhantomPinned);
impl Unpin for Bar where Wrapper<PhantomPinned>: Unpin {} //~ ERROR E0277
struct WrapperWithLifetime<'a, T>(PhantomData<&'a ()>, T);
impl<T> Unpin for WrapperWithLifetime<'_, T> where T: Unpin {}
struct Baz(PhantomPinned);
impl<'a> Unpin for Baz where WrapperWithLifetime<'a, PhantomPinned>: Unpin {}
// Ok
}
fn inner() {
struct Inner(PhantomPinned);
struct Foo(Inner);
impl Unpin for Foo where Inner: Unpin {} //~ ERROR E0277
struct Wrapper<T>(T);
impl<T> Unpin for Wrapper<T> where T: Unpin {}
struct Bar(Inner);
impl Unpin for Bar where Wrapper<Inner>: Unpin {} //~ ERROR E0277
struct WrapperWithLifetime<'a, T>(PhantomData<&'a ()>, T);
impl<T> Unpin for WrapperWithLifetime<'_, T> where T: Unpin {}
struct Baz(Inner);
impl<'a> Unpin for Baz where WrapperWithLifetime<'a, Inner>: Unpin {} // Ok
}
fn main() {}