Skip to content

Commit a4a58c4

Browse files
committed
Auto merge of rust-lang#74526 - erikdesjardins:reftrack, r=Mark-Simulacrum
Add track_caller to RefCell::{borrow, borrow_mut} So panic messages point at the offending borrow. Fixes rust-lang#74472
2 parents 40a81b0 + 46be96c commit a4a58c4

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

core/src/cell.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,7 @@ impl<T: ?Sized> RefCell<T> {
788788
/// ```
789789
#[stable(feature = "rust1", since = "1.0.0")]
790790
#[inline]
791+
#[track_caller]
791792
pub fn borrow(&self) -> Ref<'_, T> {
792793
self.try_borrow().expect("already mutably borrowed")
793794
}
@@ -863,6 +864,7 @@ impl<T: ?Sized> RefCell<T> {
863864
/// ```
864865
#[stable(feature = "rust1", since = "1.0.0")]
865866
#[inline]
867+
#[track_caller]
866868
pub fn borrow_mut(&self) -> RefMut<'_, T> {
867869
self.try_borrow_mut().expect("already borrowed")
868870
}

0 commit comments

Comments
 (0)