Skip to content

Commit 6671c90

Browse files
committed
Don't rely on unspecified struct layouts in miri test
With additional range metadata the lengh of a wide ref can become the niche and therefore the pointer will be the padding instead.
1 parent 78ab350 commit 6671c90

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Diff for: src/tools/miri/tests/fail/uninit/padding-wide-ptr.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
use std::mem;
22

3-
// If this is `None`, the metadata becomes padding.
4-
type T = Option<&'static str>;
3+
#[repr(C)]
4+
struct RefAndLen {
5+
ptr: &'static u8,
6+
len: usize,
7+
}
8+
9+
// If this is `None`, the len becomes padding.
10+
type T = Option<RefAndLen>;
511

612
fn main() {
713
unsafe {

0 commit comments

Comments
 (0)