diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:59:35 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:59:35 +0000 |
commit | d1b2d29528b7794b41e66fc2136e395a02f8529b (patch) | |
tree | a4a17504b260206dec3cf55b2dca82929a348ac2 /library/core/src/fmt | |
parent | Releasing progress-linux version 1.72.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.tar.xz rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.zip |
Merging upstream version 1.73.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/core/src/fmt')
-rw-r--r-- | library/core/src/fmt/builders.rs | 6 | ||||
-rw-r--r-- | library/core/src/fmt/mod.rs | 20 |
2 files changed, 8 insertions, 18 deletions
diff --git a/library/core/src/fmt/builders.rs b/library/core/src/fmt/builders.rs index 36f49d51c..d2c9f9800 100644 --- a/library/core/src/fmt/builders.rs +++ b/library/core/src/fmt/builders.rs @@ -518,7 +518,7 @@ impl<'a, 'b: 'a> DebugSet<'a, 'b> { /// fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { /// fmt.debug_set() /// .entries(self.0.iter()) - /// .finish() // Ends the struct formatting. + /// .finish() // Ends the set formatting. /// } /// } /// @@ -648,7 +648,7 @@ impl<'a, 'b: 'a> DebugList<'a, 'b> { /// fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { /// fmt.debug_list() /// .entries(self.0.iter()) - /// .finish() // Ends the struct formatting. + /// .finish() // Ends the list formatting. /// } /// } /// @@ -905,7 +905,7 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> { /// fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { /// fmt.debug_map() /// .entries(self.0.iter().map(|&(ref k, ref v)| (k, v))) - /// .finish() // Ends the struct formatting. + /// .finish() // Ends the map formatting. /// } /// } /// diff --git a/library/core/src/fmt/mod.rs b/library/core/src/fmt/mod.rs index 1786b309c..9ce6093f1 100644 --- a/library/core/src/fmt/mod.rs +++ b/library/core/src/fmt/mod.rs @@ -2521,22 +2521,12 @@ impl<T: Copy + Debug> Debug for Cell<T> { #[stable(feature = "rust1", since = "1.0.0")] impl<T: ?Sized + Debug> Debug for RefCell<T> { fn fmt(&self, f: &mut Formatter<'_>) -> Result { + let mut d = f.debug_struct("RefCell"); match self.try_borrow() { - Ok(borrow) => f.debug_struct("RefCell").field("value", &borrow).finish(), - Err(_) => { - // The RefCell is mutably borrowed so we can't look at its value - // here. Show a placeholder instead. - struct BorrowedPlaceholder; - - impl Debug for BorrowedPlaceholder { - fn fmt(&self, f: &mut Formatter<'_>) -> Result { - f.write_str("<borrowed>") - } - } - - f.debug_struct("RefCell").field("value", &BorrowedPlaceholder).finish() - } - } + Ok(borrow) => d.field("value", &borrow), + Err(_) => d.field("value", &format_args!("<borrowed>")), + }; + d.finish() } } |