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

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

22 lines
444 B
Rust
Raw Normal View History

2025-06-29 23:13:37 +05:00
//! Test negative Sync implementation on structs.
//!
//! 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;
2025-06-29 23:13:37 +05:00
struct NotSync {
value: isize,
}
impl !Sync for NotSync {}
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 not_sync = NotSync { value: 5 };
requires_sync(not_sync);
//~^ ERROR `NotSync` cannot be shared between threads safely [E0277]
}