diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-07-11 10:29:02 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-07-11 10:29:02 +0000 |
| commit | 3f4cf59323304a2e785aba564a6eb3bd473d5499 (patch) | |
| tree | 7bec386526f8db5205a38149c6e8a1622009d8c6 | |
| parent | 984db78d771ec67d781e954da759dbea8667197a (diff) | |
| download | rust-3f4cf59323304a2e785aba564a6eb3bd473d5499.tar.gz rust-3f4cf59323304a2e785aba564a6eb3bd473d5499.zip | |
Move checks to compile-time
| -rw-r--r-- | src/test/ui/layout/unsafe-cell-hides-niche.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/test/ui/layout/unsafe-cell-hides-niche.rs b/src/test/ui/layout/unsafe-cell-hides-niche.rs index bb2156a5da7..385472ac88a 100644 --- a/src/test/ui/layout/unsafe-cell-hides-niche.rs +++ b/src/test/ui/layout/unsafe-cell-hides-niche.rs @@ -3,7 +3,7 @@ // test checks that an `Option<UnsafeCell<NonZeroU32>>` has the same // size in memory as an `Option<UnsafeCell<u32>>` (namely, 8 bytes). -// run-pass +// check-pass #![feature(repr_simd)] @@ -19,6 +19,13 @@ struct Transparent<T>(T); struct NoNiche<T>(UnsafeCell<T>); +// Overwriting the runtime assertion and making it a compile-time assertion +macro_rules! assert_eq { + ($a:expr, $b:literal) => {{ + const _: () = assert!($a == $b); + }}; +} + fn main() { assert_eq!(size_of::<Option<Wrapper<u32>>>(), 8); assert_eq!(size_of::<Option<Wrapper<N32>>>(), 4); // (✓ niche opt) |
