about summary refs log tree commit diff
path: root/tests/ui/sync/reentrantlockguard-sync.rs
blob: 84d5b1834a882adf857e6b0cef20ff393fbfa2bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#![feature(reentrant_lock)]
use std::sync::ReentrantLock;
use std::cell::Cell;

// ReentrantLockGuard<Cell<i32>> must not be Sync, that would be unsound.

fn test_sync<T: Sync>(_t: T) {}

fn main()
{
    let m = ReentrantLock::new(Cell::new(0i32));
    let guard = m.lock();
    test_sync(guard);
    //~^ ERROR `Cell<i32>` cannot be shared between threads safely [E0277]
}