Rollup merge of #105682 - thomcc:expose-ptr-fmt, r=RalfJung

Use `expose_addr()` in `fmt::Pointer`

Discussion in https://rust-lang.zulipchat.com/#narrow/stream/136281-t-lang.2Fwg-unsafe-code-guidelines/topic/Should.20.60fmt.3A.3APointer.60.20expose.20the.20argument.3F on whether or not we should do this (still undecided).

CC `@RalfJung`
This commit is contained in:
Dylan DPC 2022-12-19 14:41:34 +05:30 committed by GitHub
commit f74bcfbdb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2471,8 +2471,8 @@ impl Display for char {
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> Pointer for *const T {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
// Cast is needed here because `.addr()` requires `T: Sized`.
pointer_fmt_inner((*self as *const ()).addr(), f)
// Cast is needed here because `.expose_addr()` requires `T: Sized`.
pointer_fmt_inner((*self as *const ()).expose_addr(), f)
}
}