]> git.lizzy.rs Git - rust.git/blob - tests/ui/phantom-auto-trait.rs
Rollup merge of #107740 - oli-obk:lock_tcx, r=petrochenkov
[rust.git] / tests / ui / phantom-auto-trait.rs
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).
3
4 #![feature(auto_traits)]
5
6 use std::marker::{PhantomData};
7
8 unsafe auto trait Zen {}
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>) {
21     is_zen(x)
22     //~^ ERROR `T` cannot be shared between threads safely [E0277]
23 }
24
25 fn nested_not_sync<T>(x: Nested<Guard<T>>) {
26     is_zen(x)
27     //~^ ERROR `T` cannot be shared between threads safely [E0277]
28 }
29
30 fn main() {}