We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 76c5229 commit aa1db24Copy full SHA for aa1db24
src/test/run-pass/union/union-nonzero.rs
@@ -24,10 +24,18 @@ union U2<A: Copy, B: Copy> {
24
b: B,
25
}
26
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
+
34
fn main() {
35
// Unions do not participate in niche-filling/non-zero optimization...
36
assert!(size_of::<Option<U2<&u8, u8>>>() > size_of::<U2<&u8, u8>>());
37
assert!(size_of::<Option<U2<&u8, ()>>>() > size_of::<U2<&u8, ()>>());
38
+ assert!(size_of::<Option<U2<u8, E>>>() > size_of::<U2<u8, E>>());
39
40
// ...even when theoretically possible:
41
assert!(size_of::<Option<U1<&u8>>>() > size_of::<U1<&u8>>());
0 commit comments