diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2023-10-10 14:06:30 +0200 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2024-01-16 19:09:18 +0100 |
commit | 906e55530a30fed93868d16332c9168848089ded (patch) | |
tree | 70db6d340050c692d21f81ea8045f194dc08e003 /gcc | |
parent | 2dfff621d9f5e2f7635a505d3d8c89ce1181f90e (diff) | |
download | gcc-906e55530a30fed93868d16332c9168848089ded.zip gcc-906e55530a30fed93868d16332c9168848089ded.tar.gz gcc-906e55530a30fed93868d16332c9168848089ded.tar.bz2 |
gccrs: Break OR tokens in closure parameter list context
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>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/parse/rust-parse-impl.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 71f76f8..1e59913 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -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 (); } |