Skip to content

Commit 46be96c

Browse files
add track_caller to RefCell::{borrow, borrow_mut}
So panic messages point at the offending borrow.
1 parent 393c968 commit 46be96c

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)