Skip to content

Commit 409d994

Browse files
committed
change test to use if black_box(false)
1 parent d8fb568 commit 409d994

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

Diff for: tests/ui/panic-handler/weak-lang-item-2.rs

+6-14
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,15 @@
11
// run-pass
22
// aux-build:weak-lang-items.rs
33

4-
// ignore-emscripten no threads support
54
// pretty-expanded FIXME #23616
65

76
extern crate weak_lang_items as other;
87

98
fn main() {
10-
let _ = std::thread::spawn(move || {
11-
// The goal of the test is just to make sure other::foo() is called. Since the function
12-
// panics, it's executed in its own thread. That way, the panic is isolated within the
13-
// thread and wont't affect the overall exit code.
14-
//
15-
// That causes a spurious failures in panic=abort targets though: if the program exits
16-
// before the thread is fully initialized the test will pass, but if the thread gets
17-
// executed first the whole program will abort. Adding a 60 seconds sleep will (hopefully!)
18-
// ensure the program always exits before the thread is executed.
19-
std::thread::sleep(std::time::Duration::from_secs(60));
20-
21-
other::foo()
22-
});
9+
// The goal of the test is just to make sure other::foo() is referenced at link time. Since
10+
// the function panics, to prevent it from running we gate it behind an always-false `if` that
11+
// is not going to be optimized away.
12+
if std::hint::black_box(false) {
13+
other::foo();
14+
}
2315
}

0 commit comments

Comments
 (0)