File tree 1 file changed +13
-10
lines changed
src/tools/miri/tests/pass/tls
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) ]
3
2
4
3
use std:: cell:: Cell ;
5
4
@@ -8,16 +7,20 @@ use std::cell::Cell;
8
7
//
9
8
// The test covers both TLS statics and the TLS macro.
10
9
pub 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
-
19
10
#[ thread_local]
20
11
static TLS : Cell < Option < & ' static i32 > > = Cell :: new ( None ) ;
21
12
22
13
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
+ }
23
26
}
You can’t perform that action at this time.
0 commit comments