Skip to content

Commit 57161b5

Browse files
committed
Check CI env vars and tweak output
1 parent a9f12e2 commit 57161b5

File tree

3 files changed

+34
-7
lines changed

3 files changed

+34
-7
lines changed

Cargo.lock

+29
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,15 @@ dependencies = [
635635
"winapi",
636636
]
637637

638+
[[package]]
639+
name = "ci_info"
640+
version = "0.14.9"
641+
source = "registry+https://github.com/rust-lang/crates.io-index"
642+
checksum = "62a62f39080c8c83e899dff6abd46c4fac05c1cf8dafece96ad8238e79addbf8"
643+
dependencies = [
644+
"envmnt",
645+
]
646+
638647
[[package]]
639648
name = "clap"
640649
version = "3.2.20"
@@ -1424,6 +1433,16 @@ dependencies = [
14241433
"termcolor",
14251434
]
14261435

1436+
[[package]]
1437+
name = "envmnt"
1438+
version = "0.10.4"
1439+
source = "registry+https://github.com/rust-lang/crates.io-index"
1440+
checksum = "d73999a2b8871e74c8b8bc23759ee9f3d85011b24fafc91a4b3b5c8cc8185501"
1441+
dependencies = [
1442+
"fsio",
1443+
"indexmap",
1444+
]
1445+
14271446
[[package]]
14281447
name = "errno"
14291448
version = "0.2.8"
@@ -1629,6 +1648,15 @@ version = "1.1.0"
16291648
source = "registry+https://github.com/rust-lang/crates.io-index"
16301649
checksum = "5f2a4a2034423744d2cc7ca2068453168dcdb82c438419e639a26bd87839c674"
16311650

1651+
[[package]]
1652+
name = "fsio"
1653+
version = "0.4.0"
1654+
source = "registry+https://github.com/rust-lang/crates.io-index"
1655+
checksum = "dad0ce30be0cc441b325c5d705c8b613a0ca0d92b6a8953d41bd236dc09a36d0"
1656+
dependencies = [
1657+
"dunce",
1658+
]
1659+
16321660
[[package]]
16331661
name = "futf"
16341662
version = "0.1.5"
@@ -3949,6 +3977,7 @@ version = "0.0.0"
39493977
dependencies = [
39503978
"backtrace",
39513979
"chrono 0.2.25",
3980+
"ci_info",
39523981
"libc",
39533982
"rustc_ast",
39543983
"rustc_ast_pretty",

compiler/rustc_driver/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ crate-type = ["dylib"]
1010
backtrace = "0.3.66"
1111
serde_json = "1.0.59"
1212
chrono = "0.2"
13+
ci_info = "0.14.9"
1314
urlqstring = "*"
1415
tracing = { version = "0.1.35" }
1516
rustc_log = { path = "../rustc_log" }

compiler/rustc_driver/src/lib.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -1216,8 +1216,6 @@ fn write_ice_to_disk(info: &panic::PanicInfo<'_>) -> Result<(String, String), Ic
12161216

12171217
writeln!(file, "{}", version)?;
12181218
args.push(("version", version.as_str()));
1219-
let backtrace_msg = format!("please include the contents of `{}` here", path.display());
1220-
args.push(("backtrace", &backtrace_msg));
12211219

12221220
if let Some((flags, excluded_cargo_defaults)) = extra_compiler_flags() {
12231221
writeln!(file, "compiler flags:")?;
@@ -1229,8 +1227,6 @@ fn write_ice_to_disk(info: &panic::PanicInfo<'_>) -> Result<(String, String), Ic
12291227
}
12301228
}
12311229
writeln!(file, "")?;
1232-
let mut text = String::new();
1233-
text.push_str(&format!("{:?} {:?}", info.message(), info.location()));
12341230
match (info.message(), info.location()) {
12351231
(Some(message), Some(location)) => {
12361232
writeln!(file, "panicked at {location}:\n{message}")?;
@@ -1247,6 +1243,7 @@ fn write_ice_to_disk(info: &panic::PanicInfo<'_>) -> Result<(String, String), Ic
12471243
}
12481244

12491245
writeln!(file, "")?;
1246+
let capture = format!("{capture}");
12501247
writeln!(file, "{capture}")?;
12511248

12521249
// Be careful relying on global state here: this code is called from
@@ -1304,7 +1301,8 @@ static DEFAULT_HOOK: LazyLock<Box<dyn Fn(&panic::PanicInfo<'_>) + Sync + Send +
13041301
&& std::env::var("RUSTC_BACKTRACE_FORCE").as_deref() != Ok("0")
13051302
},
13061303
);
1307-
let written_ice = if !is_dev { write_ice_to_disk(info) } else { Err(IceError) };
1304+
let written_ice =
1305+
if !is_dev && !ci_info::is_ci() { write_ice_to_disk(info) } else { Err(IceError) };
13081306
// Invoke the default handler, which prints the actual panic message and optionally a backtrace
13091307
// Don't do this for delayed bugs, which already emit their own more useful backtrace.
13101308
if !info.payload().is::<rustc_errors::DelayedBugPanic>() && written_ice.is_err() {
@@ -1359,8 +1357,7 @@ pub fn report_ice(
13591357
}
13601358

13611359
let xs: Vec<Cow<'static, str>> = if let Some((path, custom_url)) = &reported_ice {
1362-
let link = format!("\x1b]8;;{custom_url}\x1b\\{bug_report_url}\x1b]8;;\x1b\\");
1363-
let path = format!("\x1b]8;;file://{path}\x1b\\{path}\x1b]8;;\x1b\\");
1360+
let link = format!("\x1b]8;;{custom_url}\x07{bug_report_url}\x1b]8;;\x07");
13641361
vec![
13651362
format!("all necessary context about this bug was written to `{path}`").into(),
13661363
format!("we would appreciate a bug report with this context at {link}").into(),

0 commit comments

Comments
 (0)