diff options
| author | Ralf Jung <post@ralfj.de> | 2022-11-05 12:35:40 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2022-11-05 15:21:50 +0100 |
| commit | aaa23925db4069a856acc881ceb27402adcd8c63 (patch) | |
| tree | 49665b9d9182fe34063f8a8701c1586a4bd7ba89 /compiler/rustc_data_structures/src | |
| parent | 4492c029eff7b42e91e759576ab0c7ca88f873dc (diff) | |
| parent | c199a3988476f50e203a6cce8e7bcd3b653055ea (diff) | |
| download | rust-aaa23925db4069a856acc881ceb27402adcd8c63.tar.gz rust-aaa23925db4069a856acc881ceb27402adcd8c63.zip | |
Merge from rustc
Diffstat (limited to 'compiler/rustc_data_structures/src')
| -rw-r--r-- | compiler/rustc_data_structures/src/sync.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/compiler/rustc_data_structures/src/sync.rs b/compiler/rustc_data_structures/src/sync.rs index 9c0fb8265cf..c550f246e09 100644 --- a/compiler/rustc_data_structures/src/sync.rs +++ b/compiler/rustc_data_structures/src/sync.rs @@ -410,6 +410,7 @@ impl<T> Lock<T> { #[cfg(parallel_compiler)] #[inline(always)] + #[track_caller] pub fn lock(&self) -> LockGuard<'_, T> { if ERROR_CHECKING { self.0.try_lock().expect("lock was already held") @@ -420,21 +421,25 @@ impl<T> Lock<T> { #[cfg(not(parallel_compiler))] #[inline(always)] + #[track_caller] pub fn lock(&self) -> LockGuard<'_, T> { self.0.borrow_mut() } #[inline(always)] + #[track_caller] pub fn with_lock<F: FnOnce(&mut T) -> R, R>(&self, f: F) -> R { f(&mut *self.lock()) } #[inline(always)] + #[track_caller] pub fn borrow(&self) -> LockGuard<'_, T> { self.lock() } #[inline(always)] + #[track_caller] pub fn borrow_mut(&self) -> LockGuard<'_, T> { self.lock() } @@ -476,6 +481,7 @@ impl<T> RwLock<T> { #[cfg(not(parallel_compiler))] #[inline(always)] + #[track_caller] pub fn read(&self) -> ReadGuard<'_, T> { self.0.borrow() } @@ -491,6 +497,7 @@ impl<T> RwLock<T> { } #[inline(always)] + #[track_caller] pub fn with_read_lock<F: FnOnce(&T) -> R, R>(&self, f: F) -> R { f(&*self.read()) } @@ -509,6 +516,7 @@ impl<T> RwLock<T> { #[cfg(not(parallel_compiler))] #[inline(always)] + #[track_caller] pub fn write(&self) -> WriteGuard<'_, T> { self.0.borrow_mut() } @@ -524,16 +532,19 @@ impl<T> RwLock<T> { } #[inline(always)] + #[track_caller] pub fn with_write_lock<F: FnOnce(&mut T) -> R, R>(&self, f: F) -> R { f(&mut *self.write()) } #[inline(always)] + #[track_caller] pub fn borrow(&self) -> ReadGuard<'_, T> { self.read() } #[inline(always)] + #[track_caller] pub fn borrow_mut(&self) -> WriteGuard<'_, T> { self.write() } |
