Skip to content

Commit f8052fc

Browse files
wesleywiserMark-Simulacrum
authored andcommitted
Add test case for unsizing with niche
1 parent f667eeb commit f8052fc

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// run-pass
2+
3+
// Check that unsizing does not change which field is considered for niche layout.
4+
5+
#![feature(offset_of)]
6+
#![allow(dead_code)]
7+
8+
#[derive(Clone)]
9+
struct WideptrField<T: ?Sized> {
10+
first: usize,
11+
second: usize,
12+
niche: NicheAtEnd,
13+
tail: T,
14+
}
15+
16+
#[derive(Clone)]
17+
#[repr(C)]
18+
struct NicheAtEnd {
19+
arr: [u8; 7],
20+
b: bool,
21+
}
22+
23+
type Tail = [bool; 8];
24+
25+
fn main() {
26+
assert_eq!(
27+
core::mem::offset_of!(WideptrField<Tail>, niche),
28+
core::mem::offset_of!(WideptrField<dyn Send>, niche)
29+
);
30+
}

0 commit comments

Comments
 (0)