Skip to content

Commit

Permalink
Auto merge of #3117 - RalfJung:catch-panic-loop, r=RalfJung
Browse files Browse the repository at this point in the history
avoid confusing loop in catch_panic test

Fixes #3115
  • Loading branch information
bors committed Oct 10, 2023
2 parents 1fffca4 + 1282eb8 commit 38b2d51
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tests/pass/panic/catch_panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

use std::cell::Cell;
use std::panic::{catch_unwind, AssertUnwindSafe};
use std::process;

thread_local! {
static MY_COUNTER: Cell<usize> = Cell::new(0);
Expand Down Expand Up @@ -62,26 +63,26 @@ fn main() {
// Built-in panics; also make sure the message is right.
test(Some("index out of bounds: the len is 3 but the index is 4"), |_old_val| {
let _val = [0, 1, 2][4];
loop {}
process::abort()
});
test(Some("attempt to divide by zero"), |_old_val| {
let _val = 1 / 0;
loop {}
process::abort()
});

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

// Assertion and debug assertion
test(None, |_old_val| {
assert!(false);
loop {}
process::abort()
});
test(None, |_old_val| {
debug_assert!(false);
loop {}
process::abort()
});

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

0 comments on commit 38b2d51

Please sign in to comment.