Skip to content

Commit fef596f

Browse files
committed
Rename assertion macro
1 parent af8536e commit fef596f

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

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

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,46 +19,46 @@ struct Transparent<T>(T);
1919
struct NoNiche<T>(UnsafeCell<T>);
2020

2121
// Overwriting the runtime assertion and making it a compile-time assertion
22-
macro_rules! assert_eq {
22+
macro_rules! assert_size {
2323
($a:ty, $b:literal) => {{
2424
const _: () = assert!(std::mem::size_of::<$a>() == $b);
2525
}};
2626
}
2727

2828
fn main() {
29-
assert_eq!(Option<Wrapper<u32>>, 8);
30-
assert_eq!(Option<Wrapper<N32>>, 4); // (✓ niche opt)
31-
assert_eq!(Option<Transparent<u32>>, 8);
32-
assert_eq!(Option<Transparent<N32>>, 4); // (✓ niche opt)
33-
assert_eq!(Option<NoNiche<u32>>, 8);
34-
assert_eq!(Option<NoNiche<N32>>, 8); // (✗ niche opt)
29+
assert_size!(Option<Wrapper<u32>>, 8);
30+
assert_size!(Option<Wrapper<N32>>, 4); // (✓ niche opt)
31+
assert_size!(Option<Transparent<u32>>, 8);
32+
assert_size!(Option<Transparent<N32>>, 4); // (✓ niche opt)
33+
assert_size!(Option<NoNiche<u32>>, 8);
34+
assert_size!(Option<NoNiche<N32>>, 8); // (✗ niche opt)
3535

36-
assert_eq!(Option<UnsafeCell<u32>>, 8);
37-
assert_eq!(Option<UnsafeCell<N32>>, 8); // (✗ niche opt)
36+
assert_size!(Option<UnsafeCell<u32>>, 8);
37+
assert_size!(Option<UnsafeCell<N32>>, 8); // (✗ niche opt)
3838

39-
assert_eq!( UnsafeCell<&()> , 8);
40-
assert_eq!(Option<UnsafeCell<&()>>, 16); // (✗ niche opt)
41-
assert_eq!( Cell<&()> , 8);
42-
assert_eq!(Option< Cell<&()>>, 16); // (✗ niche opt)
43-
assert_eq!( RefCell<&()> , 16);
44-
assert_eq!(Option< RefCell<&()>>, 24); // (✗ niche opt)
45-
assert_eq!( RwLock<&()> , 24);
46-
assert_eq!(Option< RwLock<&()>>, 32); // (✗ niche opt)
47-
assert_eq!( Mutex<&()> , 16);
48-
assert_eq!(Option< Mutex<&()>>, 24); // (✗ niche opt)
39+
assert_size!( UnsafeCell<&()> , 8);
40+
assert_size!(Option<UnsafeCell<&()>>, 16); // (✗ niche opt)
41+
assert_size!( Cell<&()> , 8);
42+
assert_size!(Option< Cell<&()>>, 16); // (✗ niche opt)
43+
assert_size!( RefCell<&()> , 16);
44+
assert_size!(Option< RefCell<&()>>, 24); // (✗ niche opt)
45+
assert_size!( RwLock<&()> , 24);
46+
assert_size!(Option< RwLock<&()>>, 32); // (✗ niche opt)
47+
assert_size!( Mutex<&()> , 16);
48+
assert_size!(Option< Mutex<&()>>, 24); // (✗ niche opt)
4949

50-
assert_eq!( UnsafeCell<&[i32]> , 16);
51-
assert_eq!(Option<UnsafeCell<&[i32]>>, 24); // (✗ niche opt)
52-
assert_eq!( UnsafeCell<(&(), &())> , 16);
53-
assert_eq!(Option<UnsafeCell<(&(), &())>>, 24); // (✗ niche opt)
50+
assert_size!( UnsafeCell<&[i32]> , 16);
51+
assert_size!(Option<UnsafeCell<&[i32]>>, 24); // (✗ niche opt)
52+
assert_size!( UnsafeCell<(&(), &())> , 16);
53+
assert_size!(Option<UnsafeCell<(&(), &())>>, 24); // (✗ niche opt)
5454

5555
trait Trait {}
56-
assert_eq!( UnsafeCell<&dyn Trait> , 16);
57-
assert_eq!(Option<UnsafeCell<&dyn Trait>>, 24); // (✗ niche opt)
56+
assert_size!( UnsafeCell<&dyn Trait> , 16);
57+
assert_size!(Option<UnsafeCell<&dyn Trait>>, 24); // (✗ niche opt)
5858

5959
#[repr(simd)]
6060
pub struct Vec4<T>([T; 4]);
6161

62-
assert_eq!( UnsafeCell<Vec4<N32>> , 16);
63-
assert_eq!(Option<UnsafeCell<Vec4<N32>>>, 32); // (✗ niche opt)
62+
assert_size!( UnsafeCell<Vec4<N32>> , 16);
63+
assert_size!(Option<UnsafeCell<Vec4<N32>>>, 32); // (✗ niche opt)
6464
}

0 commit comments

Comments
 (0)