diff options
| author | Michael Goulet <michael@errs.io> | 2023-09-07 05:33:36 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2023-09-07 05:33:36 +0000 |
| commit | b59480784dce3e02c3ce804d3fd383e2ebede465 (patch) | |
| tree | fcf065389882aaba4401820ff907fee32445dd16 /compiler/rustc_driver_impl | |
| parent | 8ad23794077b4380da05fc5dabb573f38bdb2718 (diff) | |
| download | rust-b59480784dce3e02c3ce804d3fd383e2ebede465.tar.gz rust-b59480784dce3e02c3ce804d3fd383e2ebede465.zip | |
Make ICE backtrace actually match the panic handler
Diffstat (limited to 'compiler/rustc_driver_impl')
| -rw-r--r-- | compiler/rustc_driver_impl/src/lib.rs | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index 35f4ff7d964..9cfb599aff4 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -1350,8 +1350,25 @@ pub fn install_ice_hook(bug_report_url: &'static str, extra_info: fn(&Handler)) && let Ok(mut out) = File::options().create(true).append(true).open(&ice_path) { - let _ = - write!(&mut out, "{info}{:#}", std::backtrace::Backtrace::force_capture()); + // The current implementation always returns `Some`. + let location = info.location().unwrap(); + let msg = match info.payload().downcast_ref::<&'static str>() { + Some(s) => *s, + None => match info.payload().downcast_ref::<String>() { + Some(s) => &s[..], + None => "Box<dyn Any>", + }, + }; + let thread = std::thread::current(); + let name = thread.name().unwrap_or("<unnamed>"); + let _ = write!( + &mut out, + "thread '{name}' panicked at {location}:\n\ + {msg}\n\ + stack backtrace:\n\ + {:#}", + std::backtrace::Backtrace::force_capture() + ); } } |
