about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-08-07 16:47:54 +0200
committerGitHub <noreply@github.com>2023-08-07 16:47:54 +0200
commitbf40327270d5f310c30fbbddd07c757875d991e2 (patch)
treeaf90dfcf740c8ddd9fa7b219b028cbe1c6cdba72
parent139b49b99523c43219b39079aa8fb2e084c52a1c (diff)
parent409d9946cdda6383dbfbabca696ab60f4f7a6dab (diff)
downloadrust-bf40327270d5f310c30fbbddd07c757875d991e2.tar.gz
rust-bf40327270d5f310c30fbbddd07c757875d991e2.zip
Rollup merge of #113568 - ferrocene:pa-spurious-weak-lang-item-2, r=b-naber
Fix spurious test failure with `panic=abort`

Description on why it happens and why the fix should work is in the code comments.
-rw-r--r--tests/ui/panic-handler/weak-lang-item-2.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/tests/ui/panic-handler/weak-lang-item-2.rs b/tests/ui/panic-handler/weak-lang-item-2.rs
index a429d8fabc7..2cc5f23b45e 100644
--- a/tests/ui/panic-handler/weak-lang-item-2.rs
+++ b/tests/ui/panic-handler/weak-lang-item-2.rs
@@ -1,15 +1,15 @@
 // run-pass
 // aux-build:weak-lang-items.rs
 
-// ignore-emscripten no threads support
 // pretty-expanded FIXME #23616
 
 extern crate weak_lang_items as other;
 
-use std::thread;
-
 fn main() {
-    let _ = thread::spawn(move|| {
-        other::foo()
-    });
+    // The goal of the test is just to make sure other::foo() is referenced at link time. Since
+    // the function panics, to prevent it from running we gate it behind an always-false `if` that
+    // is not going to be optimized away.
+    if std::hint::black_box(false) {
+        other::foo();
+    }
 }