2020-11-24 17:44:04 -06: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 15:20:02 -06:00
|
|
|
|
2020-11-22 21:54:31 -06:00
|
|
|
#![feature(auto_traits)]
|
2015-03-05 15:20:02 -06:00
|
|
|
|
2015-04-18 00:12:20 -05:00
|
|
|
use std::marker::{PhantomData};
|
2015-03-05 15:20:02 -06:00
|
|
|
|
2017-12-03 06:56:53 -06:00
|
|
|
unsafe auto trait Zen {}
|
2015-03-05 15:20:02 -06: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 23:01:49 -06:00
|
|
|
is_zen(x)
|
|
|
|
//~^ ERROR `T` cannot be shared between threads safely [E0277]
|
2015-03-05 15:20:02 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn nested_not_sync<T>(x: Nested<Guard<T>>) {
|
2018-02-10 23:01:49 -06:00
|
|
|
is_zen(x)
|
|
|
|
//~^ ERROR `T` cannot be shared between threads safely [E0277]
|
2015-03-05 15:20:02 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|