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
Copy file name to clipboardExpand all lines: compiler/rustc_parse/src/parser/expr.rs
+28-3
Original file line number
Diff line number
Diff line change
@@ -26,6 +26,7 @@ use rustc_macros::Subdiagnostic;
26
26
use rustc_session::errors::{ExprParenthesesNeeded, report_lit_error};
27
27
use rustc_session::lint::BuiltinLintDiag;
28
28
use rustc_session::lint::builtin::BREAK_WITH_LABEL_AND_LOOP;
29
+
use rustc_span::edition::Edition;
29
30
use rustc_span::source_map::{self,Spanned};
30
31
use rustc_span::{BytePos,ErrorGuaranteed,Ident,Pos,Span,Symbol, kw, sym};
31
32
use thin_vec::{ThinVec, thin_vec};
@@ -2605,7 +2606,7 @@ impl<'a> Parser<'a> {
2605
2606
/// Parses an `if` expression (`if` token already eaten).
2606
2607
fnparse_expr_if(&mutself) -> PResult<'a,P<Expr>>{
2607
2608
let lo = self.prev_token.span;
2608
-
let cond = self.parse_expr_cond()?;
2609
+
let cond = self.parse_expr_cond(lo.edition())?;
2609
2610
self.parse_if_after_cond(lo, cond)
2610
2611
}
2611
2612
@@ -2714,8 +2715,11 @@ impl<'a> Parser<'a> {
2714
2715
}
2715
2716
2716
2717
/// Parses the condition of a `if` or `while` expression.
2718
+
///
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..)
2717
2721
// 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