From: Arthur Cohen Date: Wed, 5 Mar 2025 15:30:04 +0000 (+0000) Subject: parser: Parse let-else statements X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=effefe8803f946e18b797d234c59e78f6fb505e9;p=thirdparty%2Fgcc.git 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. --- diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index a1b22c0a416..bd501132914 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -6163,6 +6163,10 @@ Parser::parse_let_stmt (AST::AttrVec outer_attrs, } } + tl::optional> 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::parse_let_stmt (AST::AttrVec outer_attrs, return std::unique_ptr ( 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.