Skip to content

Commit 08a2992

Browse files
committed
compiletest: Better error message for bad normalize-* headers
1 parent fdf7ea6 commit 08a2992

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/tools/compiletest/src/header.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -991,13 +991,19 @@ impl Config {
991991
}
992992

993993
fn parse_custom_normalization(&self, line: &str, prefix: &str) -> Option<(String, String)> {
994-
if parse_cfg_name_directive(self, line, prefix).outcome == MatchOutcome::Match {
995-
let (regex, replacement) = parse_normalize_rule(line)
996-
.unwrap_or_else(|| panic!("couldn't parse custom normalization rule: `{line}`"));
997-
Some((regex, replacement))
998-
} else {
999-
None
994+
let parsed = parse_cfg_name_directive(self, line, prefix);
995+
if parsed.outcome != MatchOutcome::Match {
996+
return None;
1000997
}
998+
let name = parsed.name.expect("successful match always has a name");
999+
1000+
let Some((regex, replacement)) = parse_normalize_rule(line) else {
1001+
panic!(
1002+
"couldn't parse custom normalization rule: `{line}`\n\
1003+
help: expected syntax is: `{prefix}-{name}: \"REGEX\" -> \"REPLACEMENT\"`"
1004+
);
1005+
};
1006+
Some((regex, replacement))
10011007
}
10021008

10031009
fn parse_name_directive(&self, line: &str, directive: &str) -> bool {

0 commit comments

Comments
 (0)