Skip to content

Commit 1d603db

Browse files
Rollup merge of rust-lang#77055 - est31:more_track_caller, r=Mark-Simulacrum
Add #[track_caller] to more panicking Cell functions Continuation of rust-lang#74526 Adds the #[track_caller] attribute to almost all panicking Cell functions. The ones that borrow two Cells in their function body are spared, because the panic location helps pinpoint which of the two borrows failed. You'd need to have full debuginfo and backtraces enabled together with column info in order to be able to discern the cases. Column info in debuginfo is only available on non-Windows platforms.
2 parents 51ba922 + 05c3a2b commit 1d603db

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

library/core/src/cell.rs

+3
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,7 @@ impl<T> RefCell<T> {
697697
/// ```
698698
#[inline]
699699
#[stable(feature = "refcell_replace", since = "1.24.0")]
700+
#[track_caller]
700701
pub fn replace(&self, t: T) -> T {
701702
mem::replace(&mut *self.borrow_mut(), t)
702703
}
@@ -719,6 +720,7 @@ impl<T> RefCell<T> {
719720
/// ```
720721
#[inline]
721722
#[stable(feature = "refcell_replace_swap", since = "1.35.0")]
723+
#[track_caller]
722724
pub fn replace_with<F: FnOnce(&mut T) -> T>(&self, f: F) -> T {
723725
let mut_borrow = &mut *self.borrow_mut();
724726
let replacement = f(mut_borrow);
@@ -1052,6 +1054,7 @@ impl<T: Clone> Clone for RefCell<T> {
10521054
///
10531055
/// Panics if the value is currently mutably borrowed.
10541056
#[inline]
1057+
#[track_caller]
10551058
fn clone(&self) -> RefCell<T> {
10561059
RefCell::new(self.borrow().clone())
10571060
}

0 commit comments

Comments
 (0)