Skip to content

Commit 3f4cf59

Browse files
committed
Move checks to compile-time
1 parent 984db78 commit 3f4cf59

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/test/ui/layout/unsafe-cell-hides-niche.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// test checks that an `Option<UnsafeCell<NonZeroU32>>` has the same
44
// size in memory as an `Option<UnsafeCell<u32>>` (namely, 8 bytes).
55

6-
// run-pass
6+
// check-pass
77

88
#![feature(repr_simd)]
99

@@ -19,6 +19,13 @@ struct Transparent<T>(T);
1919

2020
struct NoNiche<T>(UnsafeCell<T>);
2121

22+
// Overwriting the runtime assertion and making it a compile-time assertion
23+
macro_rules! assert_eq {
24+
($a:expr, $b:literal) => {{
25+
const _: () = assert!($a == $b);
26+
}};
27+
}
28+
2229
fn main() {
2330
assert_eq!(size_of::<Option<Wrapper<u32>>>(), 8);
2431
assert_eq!(size_of::<Option<Wrapper<N32>>>(), 4); // (✓ niche opt)

0 commit comments

Comments
 (0)