Rollup merge of #150282 - fee1-dead-contrib:push-tyqyzvmsmnyo, r=petrochenkov

move a ui test to coretests unit test

It only tests the usage and formatting of `fmt::Pointer`.
This commit is contained in:
Jonathan Brouwer 2025-12-23 12:01:02 +01:00 committed by GitHub
commit 1c50ee1956
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 24 deletions

View file

@ -76,6 +76,25 @@ fn test_fmt_debug_of_mut_reference() {
assert_eq!(format!("{:?}", &mut x), "0");
}
#[test]
fn test_fmt_pointer() {
use std::rc::Rc;
use std::sync::Arc;
let p: *const u8 = std::ptr::null();
let rc = Rc::new(1usize);
let arc = Arc::new(1usize);
let b = Box::new("hi");
let _ = format!("{rc:p}{arc:p}{b:p}");
if cfg!(target_pointer_width = "32") {
assert_eq!(format!("{:#p}", p), "0x00000000");
} else {
assert_eq!(format!("{:#p}", p), "0x0000000000000000");
}
assert_eq!(format!("{:p}", p), "0x0");
}
#[test]
fn test_default_write_impls() {
use core::fmt::Write;

View file

@ -1,24 +0,0 @@
//@ run-pass
use std::ptr;
use std::rc::Rc;
use std::sync::Arc;
fn main() {
let p: *const u8 = ptr::null();
let rc = Rc::new(1usize);
let arc = Arc::new(1usize);
let b = Box::new("hi");
let _ = format!("{:p}{:p}{:p}",
rc, arc, b);
if cfg!(target_pointer_width = "32") {
assert_eq!(format!("{:#p}", p),
"0x00000000");
} else {
assert_eq!(format!("{:#p}", p),
"0x0000000000000000");
}
assert_eq!(format!("{:p}", p),
"0x0");
}