Repository: pest-parser/pest (language: rust)

Issue:
Is the `WHITESPACE` rule name supposed to be case-sensitive ?
From the docs, it seems that `WHITESPACE` is a special rule, but `whitespace` is a normal one. However, when I define my own `whitespace` rule, it triggers a special validation routine: https://github.com/pest-parser/pest/blob/28616d951fcb937021c701696c5afaa6727b829c/meta/src/validator.rs#L407-L442 .
Looking around the code, it looks like this is the only place where the lowercase `whitespace` name is used, as opposed to `WHITESPACE`, so I think it's a bug. The same thing happens with `COMMENT`/`comment`.


Discussion / hints:

Fix patch:
diff --git a/meta/src/validator.rs b/meta/src/validator.rs
index 403ff432..c5ae4420 100644
--- a/meta/src/validator.rs
+++ b/meta/src/validator.rs
@@ -410,7 +410,7 @@ fn validate_whitespace_comment<'a, 'i: 'a>(rules: &'a [ParserRule<'i>]) -> Vec<E
     rules
         .iter()
         .filter_map(|rule| {
-            if rule.name == "whitespace" || rule.name == "comment" {
+            if rule.name == "WHITESPACE" || rule.name == "COMMENT" {
                 if is_non_failing(&rule.node.expr, &map, &mut vec![]) {
                     Some(Error::new_from_span(
                         ErrorVariant::CustomError {
@@ -608,12 +608,12 @@ mod tests {
 
  --> 1:16
   |
-1 | whitespace = { \"\" }
+1 | WHITESPACE = { \"\" }
   |                ^^
   |
-  = whitespace cannot fail and will repeat infinitely")]
+  = WHITESPACE cannot fail and will repeat infinitely")]
     fn non_failing_whitespace() {
-        let input = "whitespace = { \"\" }";
+        let input = "WHITESPACE = { \"\" }";
         unwrap_or_report(consume_rules(
             PestParser::parse(Rule::grammar_rules, input).unwrap(),
         ));
@@ -624,12 +624,12 @@ mod tests {
 
  --> 1:13
   |
-1 | comment = { soi }
+1 | COMMENT = { soi }
   |             ^-^
   |
-  = comment is non-progressing and will repeat infinitely")]
+  = COMMENT is non-progressing and will repeat infinitely")]
     fn non_progressing_comment() {
-        let input = "comment = { soi }";
+        let input = "COMMENT = { soi }";
         unwrap_or_report(consume_rules(
             PestParser::parse(Rule::grammar_rules, input).unwrap(),
         ));


Test patch: