@@ -978,10 +978,10 @@ impl Config {
978978 }
979979 }
980980
981- fn parse_custom_normalization ( & self , line : & str ) -> Option < NormalizeRule > {
981+ fn parse_custom_normalization ( & self , raw_directive : & str ) -> Option < NormalizeRule > {
982982 // FIXME(Zalathar): Integrate name/value splitting into `DirectiveLine`
983983 // instead of doing it here.
984- let ( directive_name, _value ) = line . split_once ( ':' ) ?;
984+ let ( directive_name, raw_value ) = raw_directive . split_once ( ':' ) ?;
985985
986986 let kind = match directive_name {
987987 "normalize-stdout" => NormalizeKind :: Stdout ,
@@ -991,11 +991,9 @@ impl Config {
991991 _ => return None ,
992992 } ;
993993
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 {
997995 panic ! (
998- "couldn't parse custom normalization rule: `{line }`\n \
996+ "couldn't parse custom normalization rule: `{raw_directive }`\n \
999997 help: expected syntax is: `{directive_name}: \" REGEX\" -> \" REPLACEMENT\" `"
1000998 ) ;
1001999 } ;
@@ -1141,21 +1139,21 @@ enum NormalizeKind {
11411139/// Parses the regex and replacement values of a `//@ normalize-*` header,
11421140/// in the format:
11431141/// ```text
1144- /// normalize-*: "REGEX" -> "REPLACEMENT"
1142+ /// "REGEX" -> "REPLACEMENT"
11451143/// ```
1146- fn parse_normalize_rule ( header : & str ) -> Option < ( String , String ) > {
1144+ fn parse_normalize_rule ( raw_value : & str ) -> Option < ( String , String ) > {
11471145 // FIXME: Support escaped double-quotes in strings.
11481146 let captures = static_regex ! (
11491147 r#"(?x) # (verbose mode regex)
11501148 ^
1151- [^:\s]+:\s * # (header name followed by colon )
1149+ \s * # (leading whitespace )
11521150 "(?<regex>[^"]*)" # "REGEX"
11531151 \s+->\s+ # ->
11541152 "(?<replacement>[^"]*)" # "REPLACEMENT"
11551153 $
11561154 "#
11571155 )
1158- . captures ( header ) ?;
1156+ . captures ( raw_value ) ?;
11591157 let regex = captures[ "regex" ] . to_owned ( ) ;
11601158 let replacement = captures[ "replacement" ] . to_owned ( ) ;
11611159 // FIXME: Support escaped new-line in strings.
0 commit comments