5
5
6
6
// run-pass
7
7
8
- use std:: cell:: UnsafeCell ;
8
+ use std:: cell:: { UnsafeCell , RefCell , Cell } ;
9
9
use std:: mem:: size_of;
10
10
use std:: num:: NonZeroU32 as N32 ;
11
+ use std:: sync:: { Mutex , RwLock } ;
11
12
12
13
struct Wrapper < T > ( T ) ;
13
14
@@ -18,12 +19,23 @@ struct NoNiche<T>(UnsafeCell<T>);
18
19
19
20
fn main ( ) {
20
21
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)
22
23
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)
24
25
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)
26
27
27
28
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)
29
41
}
0 commit comments