Skip to content

Commit e1aa5ad

Browse files
committed
Use YYYY-MM-DDTHH_MM_SS as datetime format for ICE dump files
Windows paths do not support `:`, so use a datetime format in ICE dump paths that Windows will accept. Fix #116809, fix #115180.
1 parent 93e62a2 commit e1aa5ad

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

compiler/rustc_driver_impl/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ rustc_target = { path = "../rustc_target" }
5252
rustc_trait_selection = { path = "../rustc_trait_selection" }
5353
rustc_ty_utils = { path = "../rustc_ty_utils" }
5454
serde_json = "1.0.59"
55-
time = { version = "0.3", default-features = false, features = ["formatting", ] }
55+
time = { version = "0.3", default-features = false, features = ["alloc", "formatting"] }
5656
tracing = { version = "0.1.35" }
5757
# tidy-alphabetical-end
5858

compiler/rustc_driver_impl/src/lib.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ use std::str;
6262
use std::sync::atomic::{AtomicBool, Ordering};
6363
use std::sync::OnceLock;
6464
use std::time::{Instant, SystemTime};
65-
use time::format_description::well_known::Rfc3339;
6665
use time::OffsetDateTime;
6766

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

tests/run-make/dump-ice-to-disk/check.sh

+6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ export RUSTC_ICE=$TMPDIR
1111
$RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-default-set.log 2>&1
1212
default_set=$(cat $TMPDIR/rustc-ice-*.txt | wc -l)
1313
content=$(cat $TMPDIR/rustc-ice-*.txt)
14+
# Ensure that the ICE dump path doesn't contain `:` because they cause problems on Windows
15+
windows_safe=$(echo rustc-ice-*.txt | grep ':')
16+
if [ ! -z "$windows_safe" ]; then
17+
exit 1
18+
fi
19+
1420
rm $TMPDIR/rustc-ice-*.txt
1521
RUST_BACKTRACE=short $RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-short.log 2>&1
1622
short=$(cat $TMPDIR/rustc-ice-*.txt | wc -l)

0 commit comments

Comments
 (0)