Skip to content

Commit aa1db24

Browse files
committed
Add non-non-zero test to union-nonzero test
1 parent 76c5229 commit aa1db24

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/test/run-pass/union/union-nonzero.rs

+8
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,18 @@ union U2<A: Copy, B: Copy> {
2424
b: B,
2525
}
2626

27+
// Option<E> uses a value other than 0 and 1 as None
28+
#[derive(Clone,Copy)]
29+
enum E {
30+
A = 0,
31+
B = 1,
32+
}
33+
2734
fn main() {
2835
// Unions do not participate in niche-filling/non-zero optimization...
2936
assert!(size_of::<Option<U2<&u8, u8>>>() > size_of::<U2<&u8, u8>>());
3037
assert!(size_of::<Option<U2<&u8, ()>>>() > size_of::<U2<&u8, ()>>());
38+
assert!(size_of::<Option<U2<u8, E>>>() > size_of::<U2<u8, E>>());
3139

3240
// ...even when theoretically possible:
3341
assert!(size_of::<Option<U1<&u8>>>() > size_of::<U1<&u8>>());

0 commit comments

Comments
 (0)