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