diff --git a/src/test/ui/layout/unsafe-cell-hides-niche.rs b/src/test/ui/layout/unsafe-cell-hides-niche.rs index 385472ac88a..f5c1fe1320c 100644 --- a/src/test/ui/layout/unsafe-cell-hides-niche.rs +++ b/src/test/ui/layout/unsafe-cell-hides-niche.rs @@ -8,7 +8,6 @@ #![feature(repr_simd)] use std::cell::{UnsafeCell, RefCell, Cell}; -use std::mem::size_of; use std::num::NonZeroU32 as N32; use std::sync::{Mutex, RwLock}; @@ -21,45 +20,45 @@ struct NoNiche(UnsafeCell); // Overwriting the runtime assertion and making it a compile-time assertion macro_rules! assert_eq { - ($a:expr, $b:literal) => {{ - const _: () = assert!($a == $b); + ($a:ty, $b:literal) => {{ + const _: () = assert!(std::mem::size_of::<$a>() == $b); }}; } fn main() { - assert_eq!(size_of::>>(), 8); - assert_eq!(size_of::>>(), 4); // (✓ niche opt) - assert_eq!(size_of::>>(), 8); - assert_eq!(size_of::>>(), 4); // (✓ niche opt) - assert_eq!(size_of::>>(), 8); - assert_eq!(size_of::>>(), 8); // (✗ niche opt) + assert_eq!(Option>, 8); + assert_eq!(Option>, 4); // (✓ niche opt) + assert_eq!(Option>, 8); + assert_eq!(Option>, 4); // (✓ niche opt) + assert_eq!(Option>, 8); + assert_eq!(Option>, 8); // (✗ niche opt) - assert_eq!(size_of::>>(), 8); - assert_eq!(size_of::>>(), 8); // (✗ niche opt) + assert_eq!(Option>, 8); + assert_eq!(Option>, 8); // (✗ niche opt) - assert_eq!(size_of::< UnsafeCell<&()> >(), 8); - assert_eq!(size_of::>>(), 16); // (✗ niche opt) - assert_eq!(size_of::< Cell<&()> >(), 8); - assert_eq!(size_of::>>(), 16); // (✗ niche opt) - assert_eq!(size_of::< RefCell<&()> >(), 16); - assert_eq!(size_of::>>(), 24); // (✗ niche opt) - assert_eq!(size_of::< RwLock<&()> >(), 24); - assert_eq!(size_of::>>(), 32); // (✗ niche opt) - assert_eq!(size_of::< Mutex<&()> >(), 16); - assert_eq!(size_of::>>(), 24); // (✗ niche opt) + assert_eq!( UnsafeCell<&()> , 8); + assert_eq!(Option>, 16); // (✗ niche opt) + assert_eq!( Cell<&()> , 8); + assert_eq!(Option< Cell<&()>>, 16); // (✗ niche opt) + assert_eq!( RefCell<&()> , 16); + assert_eq!(Option< RefCell<&()>>, 24); // (✗ niche opt) + assert_eq!( RwLock<&()> , 24); + assert_eq!(Option< RwLock<&()>>, 32); // (✗ niche opt) + assert_eq!( Mutex<&()> , 16); + assert_eq!(Option< Mutex<&()>>, 24); // (✗ niche opt) - assert_eq!(size_of::< UnsafeCell<&[i32]> >(), 16); - assert_eq!(size_of::>>(), 24); // (✗ niche opt) - assert_eq!(size_of::< UnsafeCell<(&(), &())> >(), 16); - assert_eq!(size_of::>>(), 24); // (✗ niche opt) + assert_eq!( UnsafeCell<&[i32]> , 16); + assert_eq!(Option>, 24); // (✗ niche opt) + assert_eq!( UnsafeCell<(&(), &())> , 16); + assert_eq!(Option>, 24); // (✗ niche opt) trait Trait {} - assert_eq!(size_of::< UnsafeCell<&dyn Trait> >(), 16); - assert_eq!(size_of::>>(), 24); // (✗ niche opt) + assert_eq!( UnsafeCell<&dyn Trait> , 16); + assert_eq!(Option>, 24); // (✗ niche opt) #[repr(simd)] pub struct Vec4([T; 4]); - assert_eq!(size_of::< UnsafeCell> >(), 16); - assert_eq!(size_of::>>>(), 32); // (✗ niche opt) + assert_eq!( UnsafeCell> , 16); + assert_eq!(Option>>, 32); // (✗ niche opt) }