You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 28, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: compiler/rustc_parse/src/parser/expr.rs
+45-54Lines changed: 45 additions & 54 deletions
Original file line number
Diff line number
Diff line change
@@ -2606,7 +2606,10 @@ impl<'a> Parser<'a> {
2606
2606
/// Parses an `if` expression (`if` token already eaten).
2607
2607
fnparse_expr_if(&mutself) -> PResult<'a,P<Expr>>{
2608
2608
let lo = self.prev_token.span;
2609
-
let cond = self.parse_expr_cond(lo.edition())?;
2609
+
// Scoping code checks the top level edition of the `if`; let's match it here.
2610
+
// The `CondChecker` also checks the edition of the `let` itself, just to make sure.
2611
+
let let_chains_policy = LetChainsPolicy::EditionDependent{current_edition: lo.edition()};
2612
+
let cond = self.parse_expr_cond(let_chains_policy)?;
2610
2613
self.parse_if_after_cond(lo, cond)
2611
2614
}
2612
2615
@@ -2716,41 +2719,16 @@ impl<'a> Parser<'a> {
2716
2719
2717
2720
/// Parses the condition of a `if` or `while` expression.
2718
2721
///
2719
-
/// The specified `edition` should be that of the whole `if` or `while` construct: the same
2720
-
/// span that we later decide the drop behaviour on (editions ..=2021 vs 2024..)
2722
+
/// The specified `edition` in `let_chains_policy` should be that of the whole `if` construct,
2723
+
/// i.e. the same span we use to later decide whether the drop behaviour should be that of
2724
+
/// edition `..=2021` or that of `2024..`.
2721
2725
// Public because it is used in rustfmt forks such as https://github.com/tucant/rustfmt/blob/30c83df9e1db10007bdd16dafce8a86b404329b2/src/parse/macros/html.rs#L57 for custom if expressions.
0 commit comments