// Ensure that auto trait checks `T` when it encounters a `PhantomData` field, instead of // checking the `PhantomData` type itself (which almost always implements an auto trait). #![feature(auto_traits)] use std::marker::{PhantomData}; unsafe auto trait Zen {} unsafe impl<'a, T: 'a> Zen for &'a T where T: Sync {} struct Guard<'a, T: 'a> { _marker: PhantomData<&'a T>, } struct Nested(T); fn is_zen(_: T) {} fn not_sync(x: Guard) { is_zen(x) //~^ ERROR `T` cannot be shared between threads safely [E0277] } fn nested_not_sync(x: Nested>) { is_zen(x) //~^ ERROR `T` cannot be shared between threads safely [E0277] } fn main() {}