55
66// run-pass
77
8- use std:: cell:: UnsafeCell ;
8+ use std:: cell:: { UnsafeCell , RefCell , Cell } ;
99use std:: mem:: size_of;
1010use std:: num:: NonZeroU32 as N32 ;
11+ use std:: sync:: { Mutex , RwLock } ;
1112
1213struct Wrapper < T > ( T ) ;
1314
@@ -18,12 +19,23 @@ struct NoNiche<T>(UnsafeCell<T>);
1819
1920fn main ( ) {
2021 assert_eq ! ( size_of:: <Option <Wrapper <u32 >>>( ) , 8 ) ;
21- assert_eq ! ( size_of:: <Option <Wrapper <N32 >>>( ) , 4 ) ;
22+ assert_eq ! ( size_of:: <Option <Wrapper <N32 >>>( ) , 4 ) ; // (✓ niche opt)
2223 assert_eq ! ( size_of:: <Option <Transparent <u32 >>>( ) , 8 ) ;
23- assert_eq ! ( size_of:: <Option <Transparent <N32 >>>( ) , 4 ) ;
24+ assert_eq ! ( size_of:: <Option <Transparent <N32 >>>( ) , 4 ) ; // (✓ niche opt)
2425 assert_eq ! ( size_of:: <Option <NoNiche <u32 >>>( ) , 8 ) ;
25- assert_eq ! ( size_of:: <Option <NoNiche <N32 >>>( ) , 8 ) ;
26+ assert_eq ! ( size_of:: <Option <NoNiche <N32 >>>( ) , 8 ) ; // (✗ niche opt)
2627
2728 assert_eq ! ( size_of:: <Option <UnsafeCell <u32 >>>( ) , 8 ) ;
28- assert_eq ! ( size_of:: <Option <UnsafeCell <N32 >>>( ) , 8 ) ;
29+ assert_eq ! ( size_of:: <Option <UnsafeCell <N32 >>>( ) , 8 ) ; // (✗ niche opt)
30+
31+ assert_eq ! ( size_of:: < UnsafeCell <& ( ) > >( ) , 8 ) ;
32+ assert_eq ! ( size_of:: <Option <UnsafeCell <& ( ) >>>( ) , 16 ) ; // (✗ niche opt)
33+ assert_eq ! ( size_of:: < Cell <& ( ) > >( ) , 8 ) ;
34+ assert_eq ! ( size_of:: <Option < Cell <& ( ) >>>( ) , 16 ) ; // (✗ niche opt)
35+ assert_eq ! ( size_of:: < RefCell <& ( ) > >( ) , 16 ) ;
36+ assert_eq ! ( size_of:: <Option < RefCell <& ( ) >>>( ) , 24 ) ; // (✗ niche opt)
37+ assert_eq ! ( size_of:: < RwLock <& ( ) > >( ) , 24 ) ;
38+ assert_eq ! ( size_of:: <Option < RwLock <& ( ) >>>( ) , 32 ) ; // (✗ niche opt)
39+ assert_eq ! ( size_of:: < Mutex <& ( ) > >( ) , 16 ) ;
40+ assert_eq ! ( size_of:: <Option < Mutex <& ( ) >>>( ) , 24 ) ; // (✗ niche opt)
2941}
0 commit comments