Skip to content

Commit 64da4e1

Browse files
committed
fmt: Assume that we'll only ever see 32 or 64 bit pointers
1 parent d8bb080 commit 64da4e1

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

src/libcore/fmt/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -861,8 +861,7 @@ impl<T> Pointer for *const T {
861861
// The formats need two extra bytes, for the 0x
862862
if cfg!(target_pointer_width = "32") {
863863
f.width = Some(10);
864-
}
865-
if cfg!(target_pointer_width = "64") {
864+
} else {
866865
f.width = Some(18);
867866
}
868867
}

src/test/run-pass/fmt-pointer-trait.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ fn main() {
2626
if cfg!(target_pointer_width = "32") {
2727
assert_eq!(format!("{:#p}", p),
2828
"0x00000000");
29-
}
30-
if cfg!(target_pointer_width = "64") {
29+
} else {
3130
assert_eq!(format!("{:#p}", p),
3231
"0x0000000000000000");
3332
}

src/test/run-pass/ifmt.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ pub fn main() {
7575
if cfg!(target_pointer_width = "32") {
7676
t!(format!("{:#p}", 0x1234 as *const isize), "0x00001234");
7777
t!(format!("{:#p}", 0x1234 as *mut isize), "0x00001234");
78-
}
79-
if cfg!(target_pointer_width = "64") {
78+
} else {
8079
t!(format!("{:#p}", 0x1234 as *const isize), "0x0000000000001234");
8180
t!(format!("{:#p}", 0x1234 as *mut isize), "0x0000000000001234");
8281
}

0 commit comments

Comments
 (0)