about summary refs log tree commit diff
path: root/src/tools
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-09-28 09:15:28 +0200
committerGitHub <noreply@github.com>2025-09-28 09:15:28 +0200
commit925951dddc70bed8a50faf4640642c365f903617 (patch)
treef3b0edfabb1c21c8e060290d62f87520466b761f /src/tools
parentad864de2c3eb455c39419516bae13af07fc6b61f (diff)
parentd8a1edc718537fc595dc731fcb89f17378de6af2 (diff)
downloadrust-925951dddc70bed8a50faf4640642c365f903617.tar.gz
rust-925951dddc70bed8a50faf4640642c365f903617.zip
Rollup merge of #147086 - Zalathar:payload, r=jieyouxu
compiletest: Use `PanicHookInfo::payload_as_str` now that it's stable in beta

Nice little FIXME cleanup after the bootstrap beta bump to 1.91 in https://github.com/rust-lang/rust/pull/146636.

r? jieyouxu
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/compiletest/src/panic_hook.rs15
1 files changed, 1 insertions, 14 deletions
diff --git a/src/tools/compiletest/src/panic_hook.rs b/src/tools/compiletest/src/panic_hook.rs
index 1661ca6dabe..4f1e2547518 100644
--- a/src/tools/compiletest/src/panic_hook.rs
+++ b/src/tools/compiletest/src/panic_hook.rs
@@ -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();
@@ -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")));