about summary refs log tree commit diff
path: root/library/std/src/panicking.rs
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2023-09-07 04:16:06 +0000
committerMichael Goulet <michael@errs.io>2023-09-07 04:16:06 +0000
commit8ad23794077b4380da05fc5dabb573f38bdb2718 (patch)
tree6bd668e7eb21ca1ad241f1158b59bacc5807f8c0 /library/std/src/panicking.rs
parentf00c1399987c60b4e884afc42f4aa6226855e9ae (diff)
downloadrust-8ad23794077b4380da05fc5dabb573f38bdb2718.tar.gz
rust-8ad23794077b4380da05fc5dabb573f38bdb2718.zip
Don't modify libstd to dump rustc ICEs
Diffstat (limited to 'library/std/src/panicking.rs')
-rw-r--r--library/std/src/panicking.rs36
1 files changed, 7 insertions, 29 deletions
diff --git a/library/std/src/panicking.rs b/library/std/src/panicking.rs
index b20e5464e6e..9d066c82a89 100644
--- a/library/std/src/panicking.rs
+++ b/library/std/src/panicking.rs
@@ -236,14 +236,6 @@ where
 
 /// The default panic handler.
 fn default_hook(info: &PanicInfo<'_>) {
-    panic_hook_with_disk_dump(info, None)
-}
-
-#[unstable(feature = "ice_to_disk", issue = "none")]
-/// The implementation of the default panic handler.
-///
-/// It can also write the backtrace to a given `path`. This functionality is used only by `rustc`.
-pub fn panic_hook_with_disk_dump(info: &PanicInfo<'_>, path: Option<&crate::path::Path>) {
     // If this is a double panic, make sure that we print a backtrace
     // for this panic. Otherwise only print it if logging is enabled.
     let backtrace = if info.force_no_backtrace() {
@@ -267,7 +259,7 @@ pub fn panic_hook_with_disk_dump(info: &PanicInfo<'_>, path: Option<&crate::path
     let thread = thread_info::current_thread();
     let name = thread.as_ref().and_then(|t| t.name()).unwrap_or("<unnamed>");
 
-    let write = |err: &mut dyn crate::io::Write, backtrace: Option<BacktraceStyle>| {
+    let write = |err: &mut dyn crate::io::Write| {
         let _ = writeln!(err, "thread '{name}' panicked at {location}:\n{msg}");
 
         static FIRST_PANIC: AtomicBool = AtomicBool::new(true);
@@ -281,19 +273,11 @@ pub fn panic_hook_with_disk_dump(info: &PanicInfo<'_>, path: Option<&crate::path
             }
             Some(BacktraceStyle::Off) => {
                 if FIRST_PANIC.swap(false, Ordering::SeqCst) {
-                    if let Some(path) = path {
-                        let _ = writeln!(
-                            err,
-                            "note: a backtrace for this error was stored at `{}`",
-                            path.display(),
-                        );
-                    } else {
-                        let _ = writeln!(
-                            err,
-                            "note: run with `RUST_BACKTRACE=1` environment variable to display a \
+                    let _ = writeln!(
+                        err,
+                        "note: run with `RUST_BACKTRACE=1` environment variable to display a \
                              backtrace"
-                        );
-                    }
+                    );
                 }
             }
             // If backtraces aren't supported or are forced-off, do nothing.
@@ -301,17 +285,11 @@ pub fn panic_hook_with_disk_dump(info: &PanicInfo<'_>, path: Option<&crate::path
         }
     };
 
-    if let Some(path) = path
-        && let Ok(mut out) = crate::fs::File::options().create(true).append(true).open(&path)
-    {
-        write(&mut out, BacktraceStyle::full());
-    }
-
     if let Some(local) = set_output_capture(None) {
-        write(&mut *local.lock().unwrap_or_else(|e| e.into_inner()), backtrace);
+        write(&mut *local.lock().unwrap_or_else(|e| e.into_inner()));
         set_output_capture(Some(local));
     } else if let Some(mut out) = panic_output() {
-        write(&mut out, backtrace);
+        write(&mut out);
     }
 }