mirror of
https://github.com/rust-lang/rust.git
synced 2025-10-03 10:47:16 +00:00
23 lines
495 B
Rust
23 lines
495 B
Rust
//! Test that enums inherit Sync/!Sync properties from their variants.
|
|
//!
|
|
//! Uses the unstable `negative_impls` feature to explicitly opt-out of Sync.
|
|
|
|
#![feature(negative_impls)]
|
|
|
|
use std::marker::Sync;
|
|
|
|
struct NoSync;
|
|
impl !Sync for NoSync {}
|
|
|
|
enum Container {
|
|
WithNoSync(NoSync),
|
|
}
|
|
|
|
fn requires_sync<T: Sync>(_: T) {}
|
|
|
|
fn main() {
|
|
let container = Container::WithNoSync(NoSync);
|
|
requires_sync(container);
|
|
//~^ ERROR `NoSync` cannot be shared between threads safely [E0277]
|
|
}
|