Skip to content

Commit d976a29

Browse files
authored
Rollup merge of #103845 - camsteffen:data-structures-track-caller, r=compiler-errors
Add track_caller to some Lock methods Would have helped to diagnose #103844.
2 parents d10187f + 10a5e75 commit d976a29

File tree

1 file changed

+11
-0
lines changed
  • compiler/rustc_data_structures/src

1 file changed

+11
-0
lines changed

compiler/rustc_data_structures/src/sync.rs

+11
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ impl<T> Lock<T> {
410410

411411
#[cfg(parallel_compiler)]
412412
#[inline(always)]
413+
#[track_caller]
413414
pub fn lock(&self) -> LockGuard<'_, T> {
414415
if ERROR_CHECKING {
415416
self.0.try_lock().expect("lock was already held")
@@ -420,21 +421,25 @@ impl<T> Lock<T> {
420421

421422
#[cfg(not(parallel_compiler))]
422423
#[inline(always)]
424+
#[track_caller]
423425
pub fn lock(&self) -> LockGuard<'_, T> {
424426
self.0.borrow_mut()
425427
}
426428

427429
#[inline(always)]
430+
#[track_caller]
428431
pub fn with_lock<F: FnOnce(&mut T) -> R, R>(&self, f: F) -> R {
429432
f(&mut *self.lock())
430433
}
431434

432435
#[inline(always)]
436+
#[track_caller]
433437
pub fn borrow(&self) -> LockGuard<'_, T> {
434438
self.lock()
435439
}
436440

437441
#[inline(always)]
442+
#[track_caller]
438443
pub fn borrow_mut(&self) -> LockGuard<'_, T> {
439444
self.lock()
440445
}
@@ -476,6 +481,7 @@ impl<T> RwLock<T> {
476481

477482
#[cfg(not(parallel_compiler))]
478483
#[inline(always)]
484+
#[track_caller]
479485
pub fn read(&self) -> ReadGuard<'_, T> {
480486
self.0.borrow()
481487
}
@@ -491,6 +497,7 @@ impl<T> RwLock<T> {
491497
}
492498

493499
#[inline(always)]
500+
#[track_caller]
494501
pub fn with_read_lock<F: FnOnce(&T) -> R, R>(&self, f: F) -> R {
495502
f(&*self.read())
496503
}
@@ -509,6 +516,7 @@ impl<T> RwLock<T> {
509516

510517
#[cfg(not(parallel_compiler))]
511518
#[inline(always)]
519+
#[track_caller]
512520
pub fn write(&self) -> WriteGuard<'_, T> {
513521
self.0.borrow_mut()
514522
}
@@ -524,16 +532,19 @@ impl<T> RwLock<T> {
524532
}
525533

526534
#[inline(always)]
535+
#[track_caller]
527536
pub fn with_write_lock<F: FnOnce(&mut T) -> R, R>(&self, f: F) -> R {
528537
f(&mut *self.write())
529538
}
530539

531540
#[inline(always)]
541+
#[track_caller]
532542
pub fn borrow(&self) -> ReadGuard<'_, T> {
533543
self.read()
534544
}
535545

536546
#[inline(always)]
547+
#[track_caller]
537548
pub fn borrow_mut(&self) -> WriteGuard<'_, T> {
538549
self.write()
539550
}

0 commit comments

Comments
 (0)