Rollup merge of #127607 - Zalathar:normalize-hint, r=wesleywiser · rust-lang/rust@fe564c1 (original) (raw)

File tree

1 file changed

lines changed

1 file changed

lines changed

Original file line number Diff line number Diff line change
@@ -991,13 +991,19 @@ impl Config {
991 991 }
992 992
993 993 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(|
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;
1000 997 }
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))
1001 1007 }
1002 1008
1003 1009 fn parse_name_directive(&self, line: &str, directive: &str) -> bool {