about summary refs log tree commit diff
path: root/compiler/rustc_errors/src/snippet.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-05-27 15:12:24 +0000
committerbors <bors@rust-lang.org>2023-05-27 15:12:24 +0000
commitf91b634643de14ab5156b0c084d80bd6845fb0ae (patch)
treea07e9d832fad28603386d0c2dcf91968c75c5f38 /compiler/rustc_errors/src/snippet.rs
parent82b311b4189cce2bde455f3e091ae662a382d592 (diff)
parentde607f1b5cc99d8ac773205702e184c2461d5e12 (diff)
downloadrust-f91b634643de14ab5156b0c084d80bd6845fb0ae.tar.gz
rust-f91b634643de14ab5156b0c084d80bd6845fb0ae.zip
Auto merge of #110975 - Amanieu:panic_count, r=joshtriplett
Rework handling of recursive panics

This PR makes 2 changes to how recursive panics works (a panic while handling a panic).

1. The panic count is no longer used to determine whether to force an immediate abort. This allows code like the following to work without aborting the process immediately:

```rust
struct Double;

impl Drop for Double {
    fn drop(&mut self) {
        // 2 panics are active at once, but this is fine since it is caught.
        std::panic::catch_unwind(|| panic!("twice"));
    }
}

let _d = Double;

panic!("once");
```

Rustc already generates appropriate code so that any exceptions escaping out of a `Drop` called in the unwind path will immediately abort the process.

2. Any panics while the panic hook is executing will force an immediate abort. This is necessary to avoid potential deadlocks like #110771 where a panic happens while holding the backtrace lock. We don't even try to print the panic message in this case since the panic may have been caused by `Display` impls.

Fixes #110771
Diffstat (limited to 'compiler/rustc_errors/src/snippet.rs')
0 files changed, 0 insertions, 0 deletions