Skip to content

Commit 05c3a2b

Browse files
committed
Add #[track_caller] to more panicking Cell functions
Continuation of #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 is only available on non-Windows platforms.
1 parent 285fc7d commit 05c3a2b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Diff for: library/core/src/cell.rs

+3
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,7 @@ impl<T> RefCell<T> {
700700
/// ```
701701
#[inline]
702702
#[stable(feature = "refcell_replace", since = "1.24.0")]
703+
#[track_caller]
703704
pub fn replace(&self, t: T) -> T {
704705
mem::replace(&mut *self.borrow_mut(), t)
705706
}
@@ -722,6 +723,7 @@ impl<T> RefCell<T> {
722723
/// ```
723724
#[inline]
724725
#[stable(feature = "refcell_replace_swap", since = "1.35.0")]
726+
#[track_caller]
725727
pub fn replace_with<F: FnOnce(&mut T) -> T>(&self, f: F) -> T {
726728
let mut_borrow = &mut *self.borrow_mut();
727729
let replacement = f(mut_borrow);
@@ -1056,6 +1058,7 @@ impl<T: Clone> Clone for RefCell<T> {
10561058
///
10571059
/// Panics if the value is currently mutably borrowed.
10581060
#[inline]
1061+
#[track_caller]
10591062
fn clone(&self) -> RefCell<T> {
10601063
RefCell::new(self.borrow().clone())
10611064
}

0 commit comments

Comments
 (0)