diff options
| author | bors <bors@rust-lang.org> | 2016-06-03 04:09:31 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2016-06-03 04:09:31 -0700 |
| commit | 9552bcdd92dfd09049ce9dd299b4bfc513ac075d (patch) | |
| tree | 30e4ca00974aaf0c10b6a8ac546cd5e63026fda0 /src/libstd/sync/mutex.rs | |
| parent | 95206f438f1573e95601f06b315a151de010e92f (diff) | |
| parent | fc4b35612550d833cefcd586cb13ebc0dc5a51e1 (diff) | |
| download | rust-9552bcdd92dfd09049ce9dd299b4bfc513ac075d.tar.gz rust-9552bcdd92dfd09049ce9dd299b4bfc513ac075d.zip | |
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
Diffstat (limited to 'src/libstd/sync/mutex.rs')
| -rw-r--r-- | src/libstd/sync/mutex.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index 15e69628c7a..c75a5c09146 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -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 } } |
