about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2023-07-27 12:32:22 +0000
committerEsteban Küber <esteban@kuber.com.ar>2023-07-27 14:06:27 +0000
commit656213cc83537c311d8bcfd0b8f2c68fe1594233 (patch)
treeb9818b9036f5847c4bca8da41a8ce6b4f53e8484
parentc06b2b9117d015bc0e6ce9a989435b6a47dfb339 (diff)
downloadrust-656213cc83537c311d8bcfd0b8f2c68fe1594233.tar.gz
rust-656213cc83537c311d8bcfd0b8f2c68fe1594233.zip
When flushing delayed span bugs, write to the ICE dump file even if it doesn't exist
Fix #113881.
-rw-r--r--compiler/rustc_errors/src/lib.rs4
-rw-r--r--library/std/src/panicking.rs2
2 files changed, 3 insertions, 3 deletions
diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs
index 1da02e1bb01..9772c5b8c15 100644
--- a/compiler/rustc_errors/src/lib.rs
+++ b/compiler/rustc_errors/src/lib.rs
@@ -1673,11 +1673,11 @@ impl HandlerInner {
         let backtrace = std::env::var_os("RUST_BACKTRACE").map_or(true, |x| &x != "0");
         for bug in bugs {
             if let Some(file) = self.ice_file.as_ref()
-                && let Ok(mut out) = std::fs::File::options().append(true).open(file)
+                && let Ok(mut out) = std::fs::File::options().create(true).append(true).open(file)
             {
                 let _ = write!(
                     &mut out,
-                    "\n\ndelayed span bug: {}\n{}",
+                    "delayed span bug: {}\n{}\n",
                     bug.inner.styled_message().iter().filter_map(|(msg, _)| msg.as_str()).collect::<String>(),
                     &bug.note
                 );
diff --git a/library/std/src/panicking.rs b/library/std/src/panicking.rs
index 0e90d618ad4..15285465c71 100644
--- a/library/std/src/panicking.rs
+++ b/library/std/src/panicking.rs
@@ -300,7 +300,7 @@ 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).write(true).open(&path)
+        && let Ok(mut out) = crate::fs::File::options().create(true).append(true).open(&path)
     {
         write(&mut out, BacktraceStyle::full());
     }