]>
Commit | Line | Data |
---|---|---|
fc512014 XL |
1 | // Ensure that auto trait checks `T` when it encounters a `PhantomData<T>` field, instead of |
2 | // checking the `PhantomData<T>` type itself (which almost always implements an auto trait). | |
c34b1796 | 3 | |
fc512014 | 4 | #![feature(auto_traits)] |
c34b1796 | 5 | |
9346a6ac | 6 | use std::marker::{PhantomData}; |
c34b1796 | 7 | |
2c00a5a8 | 8 | unsafe auto trait Zen {} |
c34b1796 AL |
9 | |
10 | unsafe impl<'a, T: 'a> Zen for &'a T where T: Sync {} | |
11 | ||
12 | struct Guard<'a, T: 'a> { | |
13 | _marker: PhantomData<&'a T>, | |
14 | } | |
15 | ||
16 | struct Nested<T>(T); | |
17 | ||
18 | fn is_zen<T: Zen>(_: T) {} | |
19 | ||
20 | fn not_sync<T>(x: Guard<T>) { | |
0531ce1d XL |
21 | is_zen(x) |
22 | //~^ ERROR `T` cannot be shared between threads safely [E0277] | |
c34b1796 AL |
23 | } |
24 | ||
25 | fn nested_not_sync<T>(x: Nested<Guard<T>>) { | |
0531ce1d XL |
26 | is_zen(x) |
27 | //~^ ERROR `T` cannot be shared between threads safely [E0277] | |
c34b1796 AL |
28 | } |
29 | ||
30 | fn main() {} |