Skip to content

Commit da5b546

Browse files
committed
Auto merge of #99731 - ehuss:let-chain-bracket-check, r=compiler-errors
Remove let-chain close brace check. #98633 added some checks to forbid let-expressions that aren't in a let chain. This check looks at the preceding token to determine if it is a valid let-chain position. One of those tokens it checks is the close brace `}`. However, to my understanding, it is not possible for a let chain to be preceded by a close brace. This PR removes the check to avoid any confusion. This is a followup to the discussion at #98633 (review). It wasn't clear what issues the original PR ran into, but I have run the full set of CI tests and nothing failed. I also can't conceive of a situation where this would be possible. This doesn't reject any valid code, I'm just removing it to avoid confusion to anyone looking at this code in the future.
2 parents 2a22093 + 2ce2870 commit da5b546

File tree

1 file changed

+1
-4
lines changed
  • compiler/rustc_parse/src/parser

1 file changed

+1
-4
lines changed

compiler/rustc_parse/src/parser/expr.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -2356,10 +2356,7 @@ impl<'a> Parser<'a> {
23562356
let is_in_a_let_chains_context_but_nested_in_other_expr = self.let_expr_allowed
23572357
&& !matches!(
23582358
self.prev_token.kind,
2359-
TokenKind::AndAnd
2360-
| TokenKind::CloseDelim(Delimiter::Brace)
2361-
| TokenKind::Ident(kw::If, _)
2362-
| TokenKind::Ident(kw::While, _)
2359+
TokenKind::AndAnd | TokenKind::Ident(kw::If, _) | TokenKind::Ident(kw::While, _)
23632360
);
23642361
if !self.let_expr_allowed || is_in_a_let_chains_context_but_nested_in_other_expr {
23652362
self.struct_span_err(self.token.span, "expected expression, found `let` statement")

0 commit comments

Comments
 (0)