diff options
author | Kushal Pal <kushalpal109@gmail.com> | 2024-01-23 17:23:05 +0530 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2024-02-07 12:40:21 +0100 |
commit | f89186f962421f6d972035fc4b4c20490e7b1c5b (patch) | |
tree | ed682995d2ef9d7a107c84d6f057883e62809f51 /gcc/rust/parse | |
parent | 830d4659604e4d0f6e908d1cdb5bf1638a60bb21 (diff) | |
download | gcc-f89186f962421f6d972035fc4b4c20490e7b1c5b.zip gcc-f89186f962421f6d972035fc4b4c20490e7b1c5b.tar.gz gcc-f89186f962421f6d972035fc4b4c20490e7b1c5b.tar.bz2 |
gccrs: Parse normal functions with `self` parameter correctly
Fixes #2812
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h (Parser::parse_function):
Skip token if its a COMMA.
gcc/testsuite/ChangeLog:
* rust/compile/issue-2812.rs: New test.
Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
Diffstat (limited to 'gcc/rust/parse')
-rw-r--r-- | gcc/rust/parse/rust-parse-impl.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index c622ed7..89e3731 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -2946,8 +2946,8 @@ Parser<ManagedTokenSource>::parse_function (AST::Visibility vis, && initial_param.error () != ParseSelfError::NOT_SELF) return nullptr; - if (initial_param.has_value ()) - skip_token (COMMA); + if (initial_param.has_value () && lexer.peek_token ()->get_id () == COMMA) + skip_token (); // parse function parameters (only if next token isn't right paren) std::vector<std::unique_ptr<AST::Param>> function_params; |