rust/tests/ui/panics/nested_panic_caught.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

25 lines
377 B
Rust
Raw Normal View History

2023-04-28 08:05:01 -05:00
//@ run-pass
//@ needs-unwind
// Checks that nested panics work correctly.
use std::panic::catch_unwind;
fn double() {
struct Double;
impl Drop for Double {
fn drop(&mut self) {
let _ = catch_unwind(|| panic!("twice"));
}
}
let _d = Double;
panic!("once");
}
fn main() {
assert!(catch_unwind(|| double()).is_err());
}