From: Pierre-Emmanuel Patry Date: Tue, 10 Oct 2023 12:06:30 +0000 (+0200) Subject: Break OR tokens in closure parameter list context X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0af6a9f10640f086254d07b17f9c541f3d759acd;p=thirdparty%2Fgcc.git 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 --- diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 0ffb03dd7c09..2b2ba6286657 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -14464,12 +14464,17 @@ Parser::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 (); }