Skip to content

Commit 0d5fdcc

Browse files
author
The Miri Conjob Bot
committed
fmt
1 parent cf1ef13 commit 0d5fdcc

File tree

2 files changed

+24
-20
lines changed

2 files changed

+24
-20
lines changed

src/tools/miri/tests/pass/issues/issue-3200-packed-field-offset.rs

+12-10
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ impl PackedSized {
2323
}
2424
}
2525

26-
fn main() { unsafe {
27-
let p = PackedSized { f: 0, d: [1, 2, 3, 4] };
28-
let p = p.unsize() as *const PackedUnsized;
29-
// Make sure the size computation does *not* think there is
30-
// any padding in front of the `d` field.
31-
assert_eq!(mem::size_of_val_raw(p), 1 + 4*4);
32-
// And likewise for the offset computation.
33-
let d = std::ptr::addr_of!((*p).d);
34-
assert_eq!(d.cast::<u32>().read_unaligned(), 1);
35-
} }
26+
fn main() {
27+
unsafe {
28+
let p = PackedSized { f: 0, d: [1, 2, 3, 4] };
29+
let p = p.unsize() as *const PackedUnsized;
30+
// Make sure the size computation does *not* think there is
31+
// any padding in front of the `d` field.
32+
assert_eq!(mem::size_of_val_raw(p), 1 + 4 * 4);
33+
// And likewise for the offset computation.
34+
let d = std::ptr::addr_of!((*p).d);
35+
assert_eq!(d.cast::<u32>().read_unaligned(), 1);
36+
}
37+
}

src/tools/miri/tests/pass/issues/issue-3200-packed2-field-offset.rs

+12-10
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ impl PackedSized {
2626
}
2727
}
2828

29-
fn main() { unsafe {
30-
let p = PackedSized { f: 0, d: [1, 2, 3, 4] };
31-
let p = p.unsize() as *const PackedUnsized;
32-
// Make sure the size computation correctly adds exact 1 byte of padding
33-
// in front of the `d` field.
34-
assert_eq!(mem::size_of_val_raw(p), 1 + 1 + 4*4);
35-
// And likewise for the offset computation.
36-
let d = std::ptr::addr_of!((*p).d);
37-
assert_eq!(d.cast::<u32>().read_unaligned(), 1);
38-
} }
29+
fn main() {
30+
unsafe {
31+
let p = PackedSized { f: 0, d: [1, 2, 3, 4] };
32+
let p = p.unsize() as *const PackedUnsized;
33+
// Make sure the size computation correctly adds exact 1 byte of padding
34+
// in front of the `d` field.
35+
assert_eq!(mem::size_of_val_raw(p), 1 + 1 + 4 * 4);
36+
// And likewise for the offset computation.
37+
let d = std::ptr::addr_of!((*p).d);
38+
assert_eq!(d.cast::<u32>().read_unaligned(), 1);
39+
}
40+
}

0 commit comments

Comments
 (0)