about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2024-08-17 16:38:19 +0200
committerRalf Jung <post@ralfj.de>2024-08-17 16:41:53 +0200
commit34e8245e4c68e5d2da7b4137291d370c7c119752 (patch)
treecccf3ca3aac5f018b231e93cf6af78e6ecaf3547
parent00587529867b9b93505397c7885178b656c35499 (diff)
downloadrust-34e8245e4c68e5d2da7b4137291d370c7c119752.tar.gz
rust-34e8245e4c68e5d2da7b4137291d370c7c119752.zip
tls_leak_main_thread_allowed: make test check target_thread_local
-rw-r--r--src/tools/miri/tests/pass/tls/tls_leak_main_thread_allowed.rs23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/tools/miri/tests/pass/tls/tls_leak_main_thread_allowed.rs b/src/tools/miri/tests/pass/tls/tls_leak_main_thread_allowed.rs
index 7732e3f9217..341b2280e01 100644
--- a/src/tools/miri/tests/pass/tls/tls_leak_main_thread_allowed.rs
+++ b/src/tools/miri/tests/pass/tls/tls_leak_main_thread_allowed.rs
@@ -1,5 +1,4 @@
-//@ignore-target-windows: Windows uses a different mechanism for `thread_local!`
-#![feature(thread_local)]
+#![feature(thread_local, cfg_target_thread_local)]
 
 use std::cell::Cell;
 
@@ -8,16 +7,20 @@ use std::cell::Cell;
 //
 // The test covers both TLS statics and the TLS macro.
 pub fn main() {
-    thread_local! {
-        static TLS_KEY: Cell<Option<&'static i32>> = Cell::new(None);
-    }
-
-    TLS_KEY.with(|cell| {
-        cell.set(Some(Box::leak(Box::new(123))));
-    });
-
     #[thread_local]
     static TLS: Cell<Option<&'static i32>> = Cell::new(None);
 
     TLS.set(Some(Box::leak(Box::new(123))));
+
+    // We can only ignore leaks on targets that use `#[thread_local]` statics to implement
+    // `thread_local!`. Ignore the test on targest that don't.
+    if cfg!(target_thread_local) {
+        thread_local! {
+            static TLS_KEY: Cell<Option<&'static i32>> = Cell::new(None);
+        }
+
+        TLS_KEY.with(|cell| {
+            cell.set(Some(Box::leak(Box::new(123))));
+        });
+    }
 }