]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Break OR tokens in closure parameter list context
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Tue, 10 Oct 2023 12:06:30 +0000 (14:06 +0200)
committerP-E-P <32375388+P-E-P@users.noreply.github.com>
Tue, 17 Oct 2023 22:19:46 +0000 (22:19 +0000)
The parser was unable to process as closure inside a closure because the
lexer could not differentiate an OR from two PIPE tokens.

gcc/rust/ChangeLog:

* parse/rust-parse-impl.h (Parser::parse_closure_expr_pratt): Fix
closure parsing function to handle consecutive parameter lists.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/parse/rust-parse-impl.h

index 0ffb03dd7c09c8824d0c1d61ee82168d5aef9aea..2b2ba628665764b4347e322baedcfdbf5cf8c800 100644 (file)
@@ -14464,12 +14464,17 @@ Parser<ManagedTokenSource>::parse_closure_expr_pratt (const_TokenPtr tok,
 
            if (lexer.peek_token ()->get_id () != COMMA)
              {
+               if (lexer.peek_token ()->get_id () == OR)
+                 lexer.split_current_token (PIPE, PIPE);
                // not an error but means param list is done
                break;
              }
            // skip comma
            lexer.skip_token ();
 
+           if (lexer.peek_token ()->get_id () == OR)
+             lexer.split_current_token (PIPE, PIPE);
+
            t = lexer.peek_token ();
          }