Skip to content

Commit 7176320

Browse files
committed
tests: Use as *const _ instead of .as_ptr() in ptr fmt test
Because `.as_ptr()` changes the type of the pointer (e.g. `&[u8]` becomes `*const u8` instead of `*const [u8]`), and it can't be expected that different types will be formatted the same way.
1 parent 69fd5e4 commit 7176320

File tree

1 file changed

+2
-2
lines changed
  • library/coretests/tests/fmt

1 file changed

+2
-2
lines changed

library/coretests/tests/fmt/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ fn test_format_flags() {
1515
fn test_pointer_formats_data_pointer() {
1616
let b: &[u8] = b"";
1717
let s: &str = "";
18-
assert_eq!(format!("{s:p}"), format!("{:p}", s.as_ptr()));
19-
assert_eq!(format!("{b:p}"), format!("{:p}", b.as_ptr()));
18+
assert_eq!(format!("{s:p}"), format!("{:p}", s as *const _));
19+
assert_eq!(format!("{b:p}"), format!("{:p}", b as *const _));
2020
}
2121

2222
#[test]

0 commit comments

Comments
 (0)