about summary refs log tree commit diff
path: root/tests/ui/traits/struct-negative-sync-impl.rs
blob: d32846276f6266ce27796276ad755462a00dfcd6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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 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]
}