diff --git a/library/core/src/cell.rs b/library/core/src/cell.rs index 5448ced803a09..9884b7f404e3d 100644 --- a/library/core/src/cell.rs +++ b/library/core/src/cell.rs @@ -1487,7 +1487,7 @@ impl<'b, T: ?Sized + Unsize, U: ?Sized> CoerceUnsized> for Ref<'b, #[stable(feature = "std_guard_impls", since = "1.20.0")] impl fmt::Display for Ref<'_, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - self.value.fmt(f) + (**self).fmt(f) } } @@ -1735,7 +1735,7 @@ impl<'b, T: ?Sized + Unsize, U: ?Sized> CoerceUnsized> for RefM #[stable(feature = "std_guard_impls", since = "1.20.0")] impl fmt::Display for RefMut<'_, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - self.value.fmt(f) + (**self).fmt(f) } } diff --git a/library/core/tests/cell.rs b/library/core/tests/cell.rs index f15e03076caf7..7b77b2134ccd7 100644 --- a/library/core/tests/cell.rs +++ b/library/core/tests/cell.rs @@ -73,11 +73,13 @@ fn ref_and_refmut_have_sensible_show() { let refcell = RefCell::new("foo"); let refcell_refmut = refcell.borrow_mut(); - assert!(format!("{refcell_refmut:?}").contains("foo")); + assert_eq!(format!("{refcell_refmut}"), "foo"); // Display + assert!(format!("{refcell_refmut:?}").contains("foo")); // Debug drop(refcell_refmut); let refcell_ref = refcell.borrow(); - assert!(format!("{refcell_ref:?}").contains("foo")); + assert_eq!(format!("{refcell_ref}"), "foo"); // Display + assert!(format!("{refcell_ref:?}").contains("foo")); // Debug drop(refcell_ref); }