File tree Expand file tree Collapse file tree 1 file changed +13
-10
lines changed
src/tools/miri/tests/pass/tls Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Original file line number Diff line number Diff line change 1- //@ignore-target-windows: Windows uses a different mechanism for `thread_local!`
2- #![ feature( thread_local) ]
1+ #![ feature( thread_local, cfg_target_thread_local) ]
32
43use std:: cell:: Cell ;
54
@@ -8,16 +7,20 @@ use std::cell::Cell;
87//
98// The test covers both TLS statics and the TLS macro.
109pub fn main ( ) {
11- thread_local ! {
12- static TLS_KEY : Cell <Option <& ' static i32 >> = Cell :: new( None ) ;
13- }
14-
15- TLS_KEY . with ( |cell| {
16- cell. set ( Some ( Box :: leak ( Box :: new ( 123 ) ) ) ) ;
17- } ) ;
18-
1910 #[ thread_local]
2011 static TLS : Cell < Option < & ' static i32 > > = Cell :: new ( None ) ;
2112
2213 TLS . set ( Some ( Box :: leak ( Box :: new ( 123 ) ) ) ) ;
14+
15+ // We can only ignore leaks on targets that use `#[thread_local]` statics to implement
16+ // `thread_local!`. Ignore the test on targest that don't.
17+ if cfg ! ( target_thread_local) {
18+ thread_local ! {
19+ static TLS_KEY : Cell <Option <& ' static i32 >> = Cell :: new( None ) ;
20+ }
21+
22+ TLS_KEY . with ( |cell| {
23+ cell. set ( Some ( Box :: leak ( Box :: new ( 123 ) ) ) ) ;
24+ } ) ;
25+ }
2326}
You can’t perform that action at this time.
0 commit comments