Skip to content

Commit

Permalink
Use YYYY-MM-DDTHH_MM_SS as datetime format for ICE dump files
Browse files Browse the repository at this point in the history
Windows paths do not support `:`, so use a datetime format in ICE dump
paths that Windows will accept.

Fix #116809, fix #115180.
  • Loading branch information
estebank committed Oct 16, 2023
1 parent f70779b commit 74e17b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_driver_impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
[lib]

[dependencies]
time = { version = "0.3", default-features = false, features = ["formatting", ] }
time = { version = "0.3", default-features = false, features = ["alloc", "formatting"] }
tracing = { version = "0.1.35" }
serde_json = "1.0.59"
rustc_log = { path = "../rustc_log" }
Expand Down
9 changes: 7 additions & 2 deletions compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ use std::str;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::OnceLock;
use std::time::{Instant, SystemTime};
use time::format_description::well_known::Rfc3339;
use time::OffsetDateTime;

#[allow(unused_macros)]
Expand Down Expand Up @@ -1306,7 +1305,13 @@ fn ice_path() -> &'static Option<PathBuf> {
None => std::env::current_dir().unwrap_or_default(),
};
let now: OffsetDateTime = SystemTime::now().into();
let file_now = now.format(&Rfc3339).unwrap_or_default();
let file_now = now
.format(
// Don't use a standard datetime format because Windows doesn't support `:` in paths
&time::format_description::parse("[year]-[month]-[day]T[hour]_[minute]_[second]")
.unwrap(),
)
.unwrap_or_default();
let pid = std::process::id();
path.push(format!("rustc-ice-{file_now}-{pid}.txt"));
Some(path)
Expand Down

0 comments on commit 74e17b4

Please sign in to comment.