Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8713973
std: simplify `NonNull` variance documentation
xizheyin Jun 3, 2025
5f0dd44
avoid `&mut P<T>` in `visit_expr` etc methods
fee1-dead Jun 11, 2025
810d99e
Prepare `rustc-dev` component un-remapping in the compiler
Urgau Jun 10, 2025
268fbfe
Un-remap `rustc-dev` component paths
Urgau Jun 11, 2025
a16b49b
Manually invalidate caches in SimplifyCfg.
cjgillot Jun 15, 2025
0e1db54
Windows: Use anonymous pipes in Command
ChrisDenton Jun 14, 2025
32c0cb0
Add union with default field values case test
jieyouxu Jun 16, 2025
a2d9687
Add comment.
cjgillot Jun 16, 2025
718df66
Two changes: Have BorrowError & BorrowMutError derive Debug and add
nealsid Jun 14, 2025
2fca05a
Rename BorrowFlag type to BorrowCounter
nealsid Jun 14, 2025
994794a
Handle same-crate macro for borrowck semicolon suggestion
Urgau Jun 16, 2025
2dd9cc1
Reject union default field values
jieyouxu Jun 16, 2025
1dbedaf
Refine run-make test ignores due to unpredictable `i686-pc-windows-gn…
jieyouxu Jun 16, 2025
aa8c6f8
Don't match on platform-specific directory not found message
jieyouxu Jun 17, 2025
0348a4a
Make performance of String::insert_str more precise
hkBst Mar 15, 2025
679a1a7
Rollup merge of #138538 - hkBst:patch-4, r=tgross35
workingjubilee Jun 17, 2025
be6b529
Rollup merge of #141946 - xizheyin:141933, r=jhpratt
workingjubilee Jun 17, 2025
4c48468
Rollup merge of #142216 - nealsid:refcell-logging, r=tgross35
workingjubilee Jun 17, 2025
0ab7ae0
Rollup merge of #142371 - fee1-dead-contrib:push-xqlkumzurkus, r=petr…
workingjubilee Jun 17, 2025
e39823f
Rollup merge of #142377 - Urgau:unremap-rustc-dev, r=jieyouxu
workingjubilee Jun 17, 2025
532edf5
Rollup merge of #142517 - ChrisDenton:anon-pipe, r=Mark-Simulacrum
workingjubilee Jun 17, 2025
540f68e
Rollup merge of #142542 - cjgillot:invalidate-simplify-cfg, r=SparrowLii
workingjubilee Jun 17, 2025
ac8a2cb
Rollup merge of #142563 - jieyouxu:no-more-i686-mingw, r=mati865
workingjubilee Jun 17, 2025
0945b2b
Rollup merge of #142570 - jieyouxu:disunion, r=estebank
workingjubilee Jun 17, 2025
c79a6c0
Rollup merge of #142584 - Urgau:span-borrowck-139049, r=fmease
workingjubilee Jun 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Two changes: Have BorrowError & BorrowMutError derive Debug and add
more information to Display implementation for BorrowError/BorrowMutError

- The BorrowError/BorrowMutError Debug implementations do not print
anything differently from what the derived implementation does, so we
don't need it.

- This change also adds the location field of
BorrowError/BorrowMutError to the the Display output when it is
present, rewords the error message, and uses the Display trait for
outputting the error message instead of Debug.
  • Loading branch information
nealsid committed Jun 16, 2025
commit 718df66f4f2224efd25947ca32947998436dea88
42 changes: 18 additions & 24 deletions library/core/src/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,54 +732,48 @@ pub struct RefCell<T: ?Sized> {
/// An error returned by [`RefCell::try_borrow`].
#[stable(feature = "try_borrow", since = "1.13.0")]
#[non_exhaustive]
#[derive(Debug)]
pub struct BorrowError {
#[cfg(feature = "debug_refcell")]
location: &'static crate::panic::Location<'static>,
}

#[stable(feature = "try_borrow", since = "1.13.0")]
impl Debug for BorrowError {
impl Display for BorrowError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut builder = f.debug_struct("BorrowError");

#[cfg(feature = "debug_refcell")]
builder.field("location", self.location);
let res = write!(
f,
"RefCell already mutably borrowed; a previous borrow was at {}",
self.location
);

builder.finish()
}
}
#[cfg(not(feature = "debug_refcell"))]
let res = Display::fmt("RefCell already mutably borrowed", f);

#[stable(feature = "try_borrow", since = "1.13.0")]
impl Display for BorrowError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Display::fmt("already mutably borrowed", f)
res
}
}

/// An error returned by [`RefCell::try_borrow_mut`].
#[stable(feature = "try_borrow", since = "1.13.0")]
#[non_exhaustive]
#[derive(Debug)]
pub struct BorrowMutError {
#[cfg(feature = "debug_refcell")]
location: &'static crate::panic::Location<'static>,
}

#[stable(feature = "try_borrow", since = "1.13.0")]
impl Debug for BorrowMutError {
impl Display for BorrowMutError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut builder = f.debug_struct("BorrowMutError");

#[cfg(feature = "debug_refcell")]
builder.field("location", self.location);
let res = write!(f, "RefCell already borrowed; a previous borrow was at {}", self.location);

builder.finish()
}
}
#[cfg(not(feature = "debug_refcell"))]
let res = Display::fmt("RefCell already borrowed", f);

#[stable(feature = "try_borrow", since = "1.13.0")]
impl Display for BorrowMutError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Display::fmt("already borrowed", f)
res
}
}

Expand All @@ -788,15 +782,15 @@ impl Display for BorrowMutError {
#[track_caller]
#[cold]
fn panic_already_borrowed(err: BorrowMutError) -> ! {
panic!("already borrowed: {:?}", err)
panic!("{err}")
}

// This ensures the panicking code is outlined from `borrow` for `RefCell`.
#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))]
#[track_caller]
#[cold]
fn panic_already_mutably_borrowed(err: BorrowError) -> ! {
panic!("already mutably borrowed: {:?}", err)
panic!("{err}")
}

// Positive values represent the number of `Ref` active. Negative values
Expand Down