Skip to content

Commit 6dc2e62

Browse files
committed
nullable-pointer-size.rs
1 parent 8ac9ad5 commit 6dc2e62

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

tests/ui/layout/nullable-pointer-size-optimization.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,41 @@
1+
//! Nullable pointer optimization preserves type sizes.
2+
//!
3+
//! Verifies that Option<T> has the same size as T for nullable pointer types,
4+
//! and that custom enums get the same optimization.
5+
16
//@ run-pass
27

8+
// Needs for Nothing variat in Enum
39
#![allow(dead_code)]
410

511
use std::mem;
612

7-
enum E<T> { Thing(isize, T), Nothing((), ((), ()), [i8; 0]) }
13+
enum E<T> {
14+
Thing(isize, T),
15+
Nothing((), ((), ()), [i8; 0]),
16+
}
17+
818
struct S<T>(isize, T);
919

1020
// These are macros so we get useful assert messages.
1121

1222
macro_rules! check_option {
1323
($T:ty) => {
1424
assert_eq!(mem::size_of::<Option<$T>>(), mem::size_of::<$T>());
15-
}
25+
};
1626
}
1727

1828
macro_rules! check_fancy {
1929
($T:ty) => {
2030
assert_eq!(mem::size_of::<E<$T>>(), mem::size_of::<S<$T>>());
21-
}
31+
};
2232
}
2333

2434
macro_rules! check_type {
2535
($T:ty) => {{
2636
check_option!($T);
2737
check_fancy!($T);
28-
}}
38+
}};
2939
}
3040

3141
pub fn main() {

0 commit comments

Comments
 (0)