Skip to content

Commit 380f569

Browse files
committed
WIP
1 parent 01612fe commit 380f569

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

library/core/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ test = false
1616
bench = false
1717

1818
[features]
19+
default = ["debug_refcell"]
1920
# Make panics and failed asserts immediately abort without formatting any message
2021
panic_immediate_abort = []
2122
# Choose algorithms that are optimized for binary size instead of runtime performance

library/core/src/cell.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ impl Debug for BorrowError {
743743
let mut builder = f.debug_struct("BorrowError");
744744

745745
#[cfg(feature = "debug_refcell")]
746-
builder.field("location", &format_args!("{}", self.location));
746+
builder.field("location", self.location);
747747

748748
builder.finish()
749749
}
@@ -767,12 +767,13 @@ pub struct BorrowMutError {
767767
#[stable(feature = "try_borrow", since = "1.13.0")]
768768
impl Debug for BorrowMutError {
769769
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
770-
let mut builder = f.debug_struct("BorrowMutError");
770+
write!(f, "{}", self.location)
771+
// let mut builder = f.debug_struct("BorrowMutError");
771772

772-
#[cfg(feature = "debug_refcell")]
773-
builder.field("location", &format_args!("{}", self.location));
773+
// #[cfg(feature = "debug_refcell")]
774+
// builder.field("location", self.location);
774775

775-
builder.finish()
776+
// builder.finish()
776777
}
777778
}
778779

@@ -787,23 +788,23 @@ impl Display for BorrowMutError {
787788
#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))]
788789
#[track_caller]
789790
#[cold]
790-
fn panic_already_borrowed(_err: BorrowMutError) -> ! {
791+
fn panic_already_borrowed(err: BorrowMutError) -> ! {
791792
if cfg!(feature = "debug_refcell") {
792-
panic!("cannot borrow as mutable because it is also borrowed as immutable here {:?}", _err);
793+
panic!("already borrowed here: {:?}", err);
793794
} else {
794-
panic!("cannot borrow as mutable because it is also borrowed as immutable");
795+
panic!("already borrowed");
795796
}
796797
}
797798

798799
// This ensures the panicking code is outlined from `borrow` for `RefCell`.
799800
#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))]
800801
#[track_caller]
801802
#[cold]
802-
fn panic_already_mutably_borrowed(_err: BorrowError) -> ! {
803+
fn panic_already_mutably_borrowed(err: BorrowError) -> ! {
803804
if cfg!(feature = "debug_refcell") {
804-
panic!("cannot borrow as immutable because it is also borrowed as mutable here {:?}", _err);
805+
panic!("already mutably borrowed here: {:?}", err);
805806
} else {
806-
panic!("cannot borrow as immutable because it is also borrowed as mutable");
807+
panic!("already mutably borrowed");
807808
}
808809
}
809810

0 commit comments

Comments
 (0)