Files
rust/tests/ui/traits/struct-negative-sync-impl.rs
2025-06-30 11:50:19 +05:00

22 lines
444 B
Rust

//! 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 NotSync {
value: isize,
}
impl !Sync for NotSync {}
fn requires_sync<T: Sync>(_: T) {}
fn main() {
let not_sync = NotSync { value: 5 };
requires_sync(not_sync);
//~^ ERROR `NotSync` cannot be shared between threads safely [E0277]
}