diff options
Diffstat (limited to 'tests/ui/traits/struct-negative-sync-impl.rs')
| -rw-r--r-- | tests/ui/traits/struct-negative-sync-impl.rs | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/tests/ui/traits/struct-negative-sync-impl.rs b/tests/ui/traits/struct-negative-sync-impl.rs index 7d8a36a76f2..d32846276f6 100644 --- a/tests/ui/traits/struct-negative-sync-impl.rs +++ b/tests/ui/traits/struct-negative-sync-impl.rs @@ -1,14 +1,21 @@ +//! Test negative Sync implementation on structs. +//! +//! Uses the unstable `negative_impls` feature to explicitly opt-out of Sync. + #![feature(negative_impls)] use std::marker::Sync; -struct Foo { a: isize } -impl !Sync for Foo {} +struct NotSync { + value: isize, +} + +impl !Sync for NotSync {} -fn bar<T: Sync>(_: T) {} +fn requires_sync<T: Sync>(_: T) {} fn main() { - let x = Foo { a: 5 }; - bar(x); - //~^ ERROR `Foo` cannot be shared between threads safely [E0277] + let not_sync = NotSync { value: 5 }; + requires_sync(not_sync); + //~^ ERROR `NotSync` cannot be shared between threads safely [E0277] } |
