diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-03-05 15:30:04 +0000 |
---|---|---|
committer | CohenArthur <arthur.cohen@embecosm.com> | 2025-03-25 14:26:53 +0000 |
commit | effefe8803f946e18b797d234c59e78f6fb505e9 (patch) | |
tree | 8eece5c3d89a074f9a1c4fb150da641bee98c0da /gcc/rust/parse | |
parent | b257ae69e13b870cdbf477cfcbb6aa53794f232a (diff) | |
download | gcc-effefe8803f946e18b797d234c59e78f6fb505e9.zip gcc-effefe8803f946e18b797d234c59e78f6fb505e9.tar.gz gcc-effefe8803f946e18b797d234c59e78f6fb505e9.tar.bz2 |
parser: Parse let-else statements
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h (Parser::parse_let_stmt): Add new parsing in case of `else` token.
Diffstat (limited to 'gcc/rust/parse')
-rw-r--r-- | gcc/rust/parse/rust-parse-impl.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index a1b22c0..bd50113 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -6163,6 +6163,10 @@ Parser<ManagedTokenSource>::parse_let_stmt (AST::AttrVec outer_attrs, } } + tl::optional<std::unique_ptr<AST::Expr>> else_expr = tl::nullopt; + if (maybe_skip_token (ELSE)) + else_expr = parse_block_expr (); + if (restrictions.consume_semi) { // `stmt` macro variables are parsed without a semicolon, but should be @@ -6177,7 +6181,7 @@ Parser<ManagedTokenSource>::parse_let_stmt (AST::AttrVec outer_attrs, return std::unique_ptr<AST::LetStmt> ( new AST::LetStmt (std::move (pattern), std::move (expr), std::move (type), - std::move (outer_attrs), locus)); + std::move (else_expr), std::move (outer_attrs), locus)); } // Parses a type path. |