Skip to content

Commit 3ddb048

Browse files
authored
Rollup merge of #101595 - ehuss:fix-ice-flag-report, r=tmiasko
Fix ICE report flags display. #92310 made some changes to the ICE report that displays the rustc flags, but it introduced a bug where a flag like `-Z incremental-verify-ich=yes` was being treated as-if it was `-Cincremental`. This corrupted the output and made it confusing. The cause was using `starts_with` instead of properly splitting the option. For example, with the command like `rustc foo.rs -Cincremental=/tmp/a -Zincremental-verify-ich=yes --crate-type lib` would previously look like: ``` note: compiler flags: -C incremental -Z incremental --crate-type lib ``` It now looks like: ``` note: compiler flags: -C incremental=[REDACTED] -Z incremental-verify-ich=yes --crate-type lib ``` I added a `[REDACTED]` marker for `-Cincremental` so it is a little less confusing that a value has been removed. Fixes #101588
2 parents 857a43d + ed0f037 commit 3ddb048

File tree

1 file changed

+7
-4
lines changed
  • compiler/rustc_driver/src

1 file changed

+7
-4
lines changed

compiler/rustc_driver/src/lib.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -1119,22 +1119,25 @@ fn extra_compiler_flags() -> Option<(Vec<String>, bool)> {
11191119
while let Some(arg) = args.next() {
11201120
if let Some(a) = ICE_REPORT_COMPILER_FLAGS.iter().find(|a| arg.starts_with(*a)) {
11211121
let content = if arg.len() == a.len() {
1122+
// A space-separated option, like `-C incremental=foo` or `--crate-type rlib`
11221123
match args.next() {
11231124
Some(arg) => arg.to_string(),
11241125
None => continue,
11251126
}
11261127
} else if arg.get(a.len()..a.len() + 1) == Some("=") {
1128+
// An equals option, like `--crate-type=rlib`
11271129
arg[a.len() + 1..].to_string()
11281130
} else {
1131+
// A non-space option, like `-Cincremental=foo`
11291132
arg[a.len()..].to_string()
11301133
};
1131-
if ICE_REPORT_COMPILER_FLAGS_EXCLUDE.iter().any(|exc| content.starts_with(exc)) {
1134+
let option = content.split_once('=').map(|s| s.0).unwrap_or(&content);
1135+
if ICE_REPORT_COMPILER_FLAGS_EXCLUDE.iter().any(|exc| option == *exc) {
11321136
excluded_cargo_defaults = true;
11331137
} else {
11341138
result.push(a.to_string());
1135-
match ICE_REPORT_COMPILER_FLAGS_STRIP_VALUE.iter().find(|s| content.starts_with(*s))
1136-
{
1137-
Some(s) => result.push(s.to_string()),
1139+
match ICE_REPORT_COMPILER_FLAGS_STRIP_VALUE.iter().find(|s| option == **s) {
1140+
Some(s) => result.push(format!("{}=[REDACTED]", s)),
11381141
None => result.push(content),
11391142
}
11401143
}

0 commit comments

Comments
 (0)