1
Fork 0

Fix Display for cell::{Ref,RefMut}

These guards changed to pointers in #97027, but their `Display` was
formatting that field directly, which made it show the raw pointer
value. Now we go through `Deref` to display the real value again.
This commit is contained in:
Josh Stone 2022-05-20 11:16:30 -07:00
parent 22ee39504a
commit 83abb7c18f
2 changed files with 6 additions and 4 deletions

View file

@ -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);
}