Skip to content

Commit bb943af

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 rust-lang#116809, fix rust-lang#115180.
1 parent f70779b commit bb943af

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
@@ -6,7 +6,7 @@ edition = "2021"
66
[lib]
77

88
[dependencies]
9-
time = { version = "0.3", default-features = false, features = ["formatting", ] }
9+
time = { version = "0.3", default-features = false, features = ["alloc", "formatting"] }
1010
tracing = { version = "0.1.35" }
1111
serde_json = "1.0.59"
1212
rustc_log = { path = "../rustc_log" }

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