Files
rust/tests/ui/traits/enum-negative-sync-impl.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

23 lines
495 B
Rust
Raw Normal View History

2025-06-29 23:13:37 +05:00
//! 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)]
2015-01-11 13:14:39 +01:00
use std::marker::Sync;
struct NoSync;
impl !Sync for NoSync {}
2025-06-29 23:13:37 +05:00
enum Container {
WithNoSync(NoSync),
}
2025-06-29 23:13:37 +05:00
fn requires_sync<T: Sync>(_: T) {}
fn main() {
2025-06-29 23:13:37 +05:00
let container = Container::WithNoSync(NoSync);
requires_sync(container);
//~^ ERROR `NoSync` cannot be shared between threads safely [E0277]
}