Auto merge of #33861 - Amanieu:lock_elision_fix, r=alexcrichton
Make sure Mutex and RwLock can't be re-locked on the same thread Fixes #33770 r? @alexcrichton
This commit is contained in:
commit
9552bcdd92
7 changed files with 214 additions and 11 deletions
|
|
@ -204,10 +204,14 @@ impl<T> Mutex<T> {
|
|||
/// Creates a new mutex in an unlocked state ready for use.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn new(t: T) -> Mutex<T> {
|
||||
Mutex {
|
||||
let mut m = Mutex {
|
||||
inner: box StaticMutex::new(),
|
||||
data: UnsafeCell::new(t),
|
||||
};
|
||||
unsafe {
|
||||
m.inner.lock.init();
|
||||
}
|
||||
m
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue