@@ -978,10 +978,10 @@ impl Config {
978
978
}
979
979
}
980
980
981
- fn parse_custom_normalization ( & self , line : & str ) -> Option < NormalizeRule > {
981
+ fn parse_custom_normalization ( & self , raw_directive : & str ) -> Option < NormalizeRule > {
982
982
// FIXME(Zalathar): Integrate name/value splitting into `DirectiveLine`
983
983
// instead of doing it here.
984
- let ( directive_name, _value ) = line . split_once ( ':' ) ?;
984
+ let ( directive_name, raw_value ) = raw_directive . split_once ( ':' ) ?;
985
985
986
986
let kind = match directive_name {
987
987
"normalize-stdout" => NormalizeKind :: Stdout ,
@@ -991,11 +991,9 @@ impl Config {
991
991
_ => return None ,
992
992
} ;
993
993
994
- // FIXME(Zalathar): The normalize rule parser should only care about
995
- // the value part, not the "line" (which isn't even the whole line).
996
- let Some ( ( regex, replacement) ) = parse_normalize_rule ( line) else {
994
+ let Some ( ( regex, replacement) ) = parse_normalize_rule ( raw_value) else {
997
995
panic ! (
998
- "couldn't parse custom normalization rule: `{line }`\n \
996
+ "couldn't parse custom normalization rule: `{raw_directive }`\n \
999
997
help: expected syntax is: `{directive_name}: \" REGEX\" -> \" REPLACEMENT\" `"
1000
998
) ;
1001
999
} ;
@@ -1141,21 +1139,21 @@ enum NormalizeKind {
1141
1139
/// Parses the regex and replacement values of a `//@ normalize-*` header,
1142
1140
/// in the format:
1143
1141
/// ```text
1144
- /// normalize-*: "REGEX" -> "REPLACEMENT"
1142
+ /// "REGEX" -> "REPLACEMENT"
1145
1143
/// ```
1146
- fn parse_normalize_rule ( header : & str ) -> Option < ( String , String ) > {
1144
+ fn parse_normalize_rule ( raw_value : & str ) -> Option < ( String , String ) > {
1147
1145
// FIXME: Support escaped double-quotes in strings.
1148
1146
let captures = static_regex ! (
1149
1147
r#"(?x) # (verbose mode regex)
1150
1148
^
1151
- [^:\s]+:\s * # (header name followed by colon )
1149
+ \s * # (leading whitespace )
1152
1150
"(?<regex>[^"]*)" # "REGEX"
1153
1151
\s+->\s+ # ->
1154
1152
"(?<replacement>[^"]*)" # "REPLACEMENT"
1155
1153
$
1156
1154
"#
1157
1155
)
1158
- . captures ( header ) ?;
1156
+ . captures ( raw_value ) ?;
1159
1157
let regex = captures[ "regex" ] . to_owned ( ) ;
1160
1158
let replacement = captures[ "replacement" ] . to_owned ( ) ;
1161
1159
// FIXME: Support escaped new-line in strings.
0 commit comments