Skip to content

Commit effefe8

Browse files
committed
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.
1 parent b257ae6 commit effefe8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

gcc/rust/parse/rust-parse-impl.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6163,6 +6163,10 @@ Parser<ManagedTokenSource>::parse_let_stmt (AST::AttrVec outer_attrs,
61636163
}
61646164
}
61656165

6166+
tl::optional<std::unique_ptr<AST::Expr>> else_expr = tl::nullopt;
6167+
if (maybe_skip_token (ELSE))
6168+
else_expr = parse_block_expr ();
6169+
61666170
if (restrictions.consume_semi)
61676171
{
61686172
// `stmt` macro variables are parsed without a semicolon, but should be
@@ -6177,7 +6181,7 @@ Parser<ManagedTokenSource>::parse_let_stmt (AST::AttrVec outer_attrs,
61776181

61786182
return std::unique_ptr<AST::LetStmt> (
61796183
new AST::LetStmt (std::move (pattern), std::move (expr), std::move (type),
6180-
std::move (outer_attrs), locus));
6184+
std::move (else_expr), std::move (outer_attrs), locus));
61816185
}
61826186

61836187
// Parses a type path.

0 commit comments

Comments
 (0)