Skip to content

Commit 4285885

Browse files
committed
Auto merge of rust-lang#115627 - compiler-errors:icedump-no-std, r=m-ou-se
Don't modify libstd to dump rustc ICEs Do a much simpler thing and just dump a `std::backtrace::Backtrace` to file. r? `@estebank` `@oli-obk` Fixes rust-lang#115610
2 parents 0c1379e + b606228 commit 4285885

File tree

2 files changed

+7
-32
lines changed

2 files changed

+7
-32
lines changed

std/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -637,9 +637,6 @@ pub mod alloc;
637637
// Private support modules
638638
mod panicking;
639639

640-
#[unstable(feature = "ice_to_disk", issue = "none")]
641-
pub use panicking::panic_hook_with_disk_dump;
642-
643640
#[path = "../../backtrace/src/lib.rs"]
644641
#[allow(dead_code, unused_attributes, fuzzy_provenance_casts)]
645642
mod backtrace_rs;

std/src/panicking.rs

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -236,14 +236,6 @@ where
236236

237237
/// The default panic handler.
238238
fn default_hook(info: &PanicInfo<'_>) {
239-
panic_hook_with_disk_dump(info, None)
240-
}
241-
242-
#[unstable(feature = "ice_to_disk", issue = "none")]
243-
/// The implementation of the default panic handler.
244-
///
245-
/// It can also write the backtrace to a given `path`. This functionality is used only by `rustc`.
246-
pub fn panic_hook_with_disk_dump(info: &PanicInfo<'_>, path: Option<&crate::path::Path>) {
247239
// If this is a double panic, make sure that we print a backtrace
248240
// for this panic. Otherwise only print it if logging is enabled.
249241
let backtrace = if info.force_no_backtrace() {
@@ -267,7 +259,7 @@ pub fn panic_hook_with_disk_dump(info: &PanicInfo<'_>, path: Option<&crate::path
267259
let thread = thread_info::current_thread();
268260
let name = thread.as_ref().and_then(|t| t.name()).unwrap_or("<unnamed>");
269261

270-
let write = |err: &mut dyn crate::io::Write, backtrace: Option<BacktraceStyle>| {
262+
let write = |err: &mut dyn crate::io::Write| {
271263
let _ = writeln!(err, "thread '{name}' panicked at {location}:\n{msg}");
272264

273265
static FIRST_PANIC: AtomicBool = AtomicBool::new(true);
@@ -281,37 +273,23 @@ pub fn panic_hook_with_disk_dump(info: &PanicInfo<'_>, path: Option<&crate::path
281273
}
282274
Some(BacktraceStyle::Off) => {
283275
if FIRST_PANIC.swap(false, Ordering::SeqCst) {
284-
if let Some(path) = path {
285-
let _ = writeln!(
286-
err,
287-
"note: a backtrace for this error was stored at `{}`",
288-
path.display(),
289-
);
290-
} else {
291-
let _ = writeln!(
292-
err,
293-
"note: run with `RUST_BACKTRACE=1` environment variable to display a \
276+
let _ = writeln!(
277+
err,
278+
"note: run with `RUST_BACKTRACE=1` environment variable to display a \
294279
backtrace"
295-
);
296-
}
280+
);
297281
}
298282
}
299283
// If backtraces aren't supported or are forced-off, do nothing.
300284
None => {}
301285
}
302286
};
303287

304-
if let Some(path) = path
305-
&& let Ok(mut out) = crate::fs::File::options().create(true).append(true).open(&path)
306-
{
307-
write(&mut out, BacktraceStyle::full());
308-
}
309-
310288
if let Some(local) = set_output_capture(None) {
311-
write(&mut *local.lock().unwrap_or_else(|e| e.into_inner()), backtrace);
289+
write(&mut *local.lock().unwrap_or_else(|e| e.into_inner()));
312290
set_output_capture(Some(local));
313291
} else if let Some(mut out) = panic_output() {
314-
write(&mut out, backtrace);
292+
write(&mut out);
315293
}
316294
}
317295

0 commit comments

Comments
 (0)