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};
@@ -2594,7 +2595,7 @@ impl<'a> Parser<'a> {
2594
2595
/// Parses an `if` expression (`if` token already eaten).
2595
2596
fnparse_expr_if(&mutself) -> PResult<'a,P<Expr>>{
2596
2597
let lo = self.prev_token.span;
2597
-
let cond = self.parse_expr_cond()?;
2598
+
let cond = self.parse_expr_cond(lo.edition())?;
2598
2599
self.parse_if_after_cond(lo, cond)
2599
2600
}
2600
2601
@@ -2703,8 +2704,11 @@ impl<'a> Parser<'a> {
2703
2704
}
2704
2705
2705
2706
/// Parses the condition of a `if` or `while` expression.
2707
+
///
2708
+
/// The specified `edition` should be that of the whole `if` or `while` construct: the same
2709
+
/// span that we later decide the drop behaviour on (editions ..=2021 vs 2024..)
2706
2710
// 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