Auto merge of #74526 - erikdesjardins:reftrack, r=Mark-Simulacrum
Add track_caller to RefCell::{borrow, borrow_mut} So panic messages point at the offending borrow. Fixes #74472
This commit is contained in:
commit
d8cbd9caca
2 changed files with 10 additions and 1 deletions
|
@ -788,6 +788,7 @@ impl<T: ?Sized> RefCell<T> {
|
|||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
pub fn borrow(&self) -> Ref<'_, T> {
|
||||
self.try_borrow().expect("already mutably borrowed")
|
||||
}
|
||||
|
@ -863,6 +864,7 @@ impl<T: ?Sized> RefCell<T> {
|
|||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
pub fn borrow_mut(&self) -> RefMut<'_, T> {
|
||||
self.try_borrow_mut().expect("already borrowed")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue