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! {
28
28
static HASDROP_CONST_LOCAL : HasDrop = const { HasDrop } ;
29
29
}
30
30
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
+
31
35
fn main ( ) {
32
36
assert ! ( core:: ptr:: from_ref( & FOO ) . addr( ) . is_multiple_of( 256 ) ) ;
33
37
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( 512 ) ) ;
40
+ assert ! ( thread_local_addr( & CONST_LOCAL ) . is_multiple_of( 512 ) ) ;
41
+ assert ! ( thread_local_addr( & HASDROP_LOCAL ) . is_multiple_of( 512 ) ) ;
42
+ assert ! ( thread_local_addr( & HASDROP_CONST_LOCAL ) . is_multiple_of( 512 ) ) ;
38
43
}
Original file line number Diff line number Diff line change @@ -37,15 +37,19 @@ thread_local! {
37
37
static HASDROP_CONST_LOCAL : HasDrop = const { HasDrop } ;
38
38
}
39
39
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
+
40
44
fn main ( ) {
41
45
assert ! ( core:: ptr:: from_ref( & A ) . addr( ) . is_multiple_of( 64 ) ) ;
42
46
assert ! ( core:: ptr:: from_ref( & B ) . addr( ) . is_multiple_of( 4096 ) ) ;
43
47
44
48
assert ! ( core:: ptr:: from_ref( & EXPORTED ) . addr( ) . is_multiple_of( 128 ) ) ;
45
49
unsafe { assert ! ( core:: ptr:: from_ref( & C ) . addr( ) . is_multiple_of( 128 ) ) } ;
46
50
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 ) ) ;
51
55
}
You can’t perform that action at this time.
0 commit comments