Skip to content

Commit 38b2d51

Browse files
committed
Auto merge of #3117 - RalfJung:catch-panic-loop, r=RalfJung
avoid confusing loop in catch_panic test Fixes #3115
2 parents 1fffca4 + 1282eb8 commit 38b2d51

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

tests/pass/panic/catch_panic.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
use std::cell::Cell;
77
use std::panic::{catch_unwind, AssertUnwindSafe};
8+
use std::process;
89

910
thread_local! {
1011
static MY_COUNTER: Cell<usize> = Cell::new(0);
@@ -62,26 +63,26 @@ fn main() {
6263
// Built-in panics; also make sure the message is right.
6364
test(Some("index out of bounds: the len is 3 but the index is 4"), |_old_val| {
6465
let _val = [0, 1, 2][4];
65-
loop {}
66+
process::abort()
6667
});
6768
test(Some("attempt to divide by zero"), |_old_val| {
6869
let _val = 1 / 0;
69-
loop {}
70+
process::abort()
7071
});
7172

7273
test(Some("align_offset: align is not a power-of-two"), |_old_val| {
7374
let _ = std::ptr::null::<u8>().align_offset(3);
74-
loop {}
75+
process::abort()
7576
});
7677

7778
// Assertion and debug assertion
7879
test(None, |_old_val| {
7980
assert!(false);
80-
loop {}
81+
process::abort()
8182
});
8283
test(None, |_old_val| {
8384
debug_assert!(false);
84-
loop {}
85+
process::abort()
8586
});
8687

8788
eprintln!("Success!"); // Make sure we get this in stderr

0 commit comments

Comments
 (0)