Skip to content

Commit

Permalink
Break OR tokens in closure parameter list context
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
P-E-P committed Oct 17, 2023
1 parent 813d0b9 commit 0af6a9f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions gcc/rust/parse/rust-parse-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
}

Expand Down

0 comments on commit 0af6a9f

Please sign in to comment.