]> git.proxmox.com Git - rustc.git/blame - src/test/ui/phantom-auto-trait.rs
New upstream version 1.67.1+dfsg1
[rustc.git] / src / test / ui / phantom-auto-trait.rs
CommitLineData
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 6use std::marker::{PhantomData};
c34b1796 7
2c00a5a8 8unsafe auto trait Zen {}
c34b1796
AL
9
10unsafe impl<'a, T: 'a> Zen for &'a T where T: Sync {}
11
12struct Guard<'a, T: 'a> {
13 _marker: PhantomData<&'a T>,
14}
15
16struct Nested<T>(T);
17
18fn is_zen<T: Zen>(_: T) {}
19
20fn 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
25fn 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
30fn main() {}