2020-11-24 15:44:04 -08:00
|
|
|
// Ensure that auto trait checks `T` when it encounters a `PhantomData<T>` field, instead of
|
|
|
|
// checking the `PhantomData<T>` type itself (which almost always implements an auto trait).
|
2015-03-05 16:20:02 -05:00
|
|
|
|
2020-11-22 19:54:31 -08:00
|
|
|
#![feature(auto_traits)]
|
2015-03-05 16:20:02 -05:00
|
|
|
|
2015-04-17 22:12:20 -07:00
|
|
|
use std::marker::{PhantomData};
|
2015-03-05 16:20:02 -05:00
|
|
|
|
2017-12-03 10:56:53 -02:00
|
|
|
unsafe auto trait Zen {}
|
2015-03-05 16:20:02 -05:00
|
|
|
|
|
|
|
unsafe impl<'a, T: 'a> Zen for &'a T where T: Sync {}
|
|
|
|
|
|
|
|
struct Guard<'a, T: 'a> {
|
|
|
|
_marker: PhantomData<&'a T>,
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Nested<T>(T);
|
|
|
|
|
|
|
|
fn is_zen<T: Zen>(_: T) {}
|
|
|
|
|
|
|
|
fn not_sync<T>(x: Guard<T>) {
|
2018-02-10 21:01:49 -08:00
|
|
|
is_zen(x)
|
|
|
|
//~^ ERROR `T` cannot be shared between threads safely [E0277]
|
2015-03-05 16:20:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn nested_not_sync<T>(x: Nested<Guard<T>>) {
|
2018-02-10 21:01:49 -08:00
|
|
|
is_zen(x)
|
|
|
|
//~^ ERROR `T` cannot be shared between threads safely [E0277]
|
2015-03-05 16:20:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|