File tree Expand file tree Collapse file tree 2 files changed +17
-8
lines changed
src/tools/miri/tests/pass Expand file tree Collapse file tree 2 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -28,11 +28,16 @@ thread_local! {
2828 static HASDROP_CONST_LOCAL : HasDrop = const { HasDrop } ;
2929}
3030
31+ fn thread_local_addr < T > ( key : & ' static std:: thread:: LocalKey < T > ) -> usize {
32+ key. with ( |local| core:: ptr:: from_ref :: < T > ( local) . addr ( ) )
33+ }
34+
3135fn main ( ) {
3236 assert ! ( core:: ptr:: from_ref( & FOO ) . addr( ) . is_multiple_of( 256 ) ) ;
3337 assert ! ( core:: ptr:: from_ref( & BAR ) . addr( ) . is_multiple_of( 512 ) ) ;
34- LOCAL . with ( |local| core:: ptr:: from_ref ( & local) . addr ( ) . is_multiple_of ( 512 ) ) ;
35- CONST_LOCAL . with ( |local| core:: ptr:: from_ref ( & local) . addr ( ) . is_multiple_of ( 512 ) ) ;
36- HASDROP_LOCAL . with ( |local| core:: ptr:: from_ref ( & local) . addr ( ) . is_multiple_of ( 512 ) ) ;
37- HASDROP_CONST_LOCAL . with ( |local| core:: ptr:: from_ref ( & local) . addr ( ) . is_multiple_of ( 512 ) ) ;
38+
39+ assert ! ( thread_local_addr( & LOCAL ) . is_multiple_of( 4096 ) ) ;
40+ assert ! ( thread_local_addr( & CONST_LOCAL ) . is_multiple_of( 4096 ) ) ;
41+ assert ! ( thread_local_addr( & HASDROP_LOCAL ) . is_multiple_of( 4096 ) ) ;
42+ assert ! ( thread_local_addr( & HASDROP_CONST_LOCAL ) . is_multiple_of( 4096 ) ) ;
3843}
Original file line number Diff line number Diff line change @@ -37,15 +37,19 @@ thread_local! {
3737 static HASDROP_CONST_LOCAL : HasDrop = const { HasDrop } ;
3838}
3939
40+ fn thread_local_addr < T > ( key : & ' static std:: thread:: LocalKey < T > ) -> usize {
41+ key. with ( |local| core:: ptr:: from_ref :: < T > ( local) . addr ( ) )
42+ }
43+
4044fn main ( ) {
4145 assert ! ( core:: ptr:: from_ref( & A ) . addr( ) . is_multiple_of( 64 ) ) ;
4246 assert ! ( core:: ptr:: from_ref( & B ) . addr( ) . is_multiple_of( 4096 ) ) ;
4347
4448 assert ! ( core:: ptr:: from_ref( & EXPORTED ) . addr( ) . is_multiple_of( 128 ) ) ;
4549 unsafe { assert ! ( core:: ptr:: from_ref( & C ) . addr( ) . is_multiple_of( 128 ) ) } ;
4650
47- LOCAL . with ( |local| core :: ptr :: from_ref ( & local ) . addr ( ) . is_multiple_of ( 4096 ) ) ;
48- CONST_LOCAL . with ( |local| core :: ptr :: from_ref ( & local ) . addr ( ) . is_multiple_of ( 4096 ) ) ;
49- HASDROP_LOCAL . with ( |local| core :: ptr :: from_ref ( & local ) . addr ( ) . is_multiple_of ( 4096 ) ) ;
50- HASDROP_CONST_LOCAL . with ( |local| core :: ptr :: from_ref ( & local ) . addr ( ) . is_multiple_of ( 4096 ) ) ;
51+ assert ! ( thread_local_addr ( & LOCAL ) . is_multiple_of( 4096 ) ) ;
52+ assert ! ( thread_local_addr ( & CONST_LOCAL ) . is_multiple_of( 4096 ) ) ;
53+ assert ! ( thread_local_addr ( & HASDROP_LOCAL ) . is_multiple_of( 4096 ) ) ;
54+ assert ! ( thread_local_addr ( & HASDROP_CONST_LOCAL ) . is_multiple_of( 4096 ) ) ;
5155}
You can’t perform that action at this time.
0 commit comments