Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions src/tools/compiletest/src/panic_hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fn custom_panic_hook(default_hook: &PanicHook, info: &panic::PanicHookInfo<'_>)

let thread = thread::current().name().unwrap_or("(test runner)").to_owned();
let location = get_location(info);
let payload = payload_as_str(info).unwrap_or("Box<dyn Any>");
let payload = info.payload_as_str().unwrap_or("Box<dyn Any>");
let backtrace = Backtrace::capture();

writeln!(out, "\nthread '{thread}' panicked at {location}:\n{payload}").unwrap();
Expand Down Expand Up @@ -72,19 +72,6 @@ fn get_location<'a>(info: &'a PanicHookInfo<'_>) -> &'a dyn Display {
}
}

/// FIXME(Zalathar): Replace with `PanicHookInfo::payload_as_str` when that's
/// stable in beta.
fn payload_as_str<'a>(info: &'a PanicHookInfo<'_>) -> Option<&'a str> {
let payload = info.payload();
if let Some(s) = payload.downcast_ref::<&str>() {
Some(s)
} else if let Some(s) = payload.downcast_ref::<String>() {
Some(s)
} else {
None
}
}

fn rust_backtrace_full() -> bool {
static RUST_BACKTRACE_FULL: LazyLock<bool> =
LazyLock::new(|| matches!(env::var("RUST_BACKTRACE").as_deref(), Ok("full")));
Expand Down
Loading