diff --git a/library/coretests/tests/fmt/mod.rs b/library/coretests/tests/fmt/mod.rs index 0fb099ef41911..67ba49db4d919 100644 --- a/library/coretests/tests/fmt/mod.rs +++ b/library/coretests/tests/fmt/mod.rs @@ -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; diff --git a/tests/ui/traits/fmt-pointer-trait.rs b/tests/ui/traits/fmt-pointer-trait.rs deleted file mode 100644 index edf734597f50a..0000000000000 --- a/tests/ui/traits/fmt-pointer-trait.rs +++ /dev/null @@ -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"); -}