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-3Lines changed: 28 additions & 3 deletions
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};
@@ -2479,7 +2480,7 @@ impl<'a> Parser<'a> {
2479
2480
/// Parses an `if` expression (`if` token already eaten).
2480
2481
fnparse_expr_if(&mutself) -> PResult<'a,P<Expr>>{
2481
2482
let lo = self.prev_token.span;
2482
-
let cond = self.parse_expr_cond()?;
2483
+
let cond = self.parse_expr_cond(lo.edition())?;
2483
2484
self.parse_if_after_cond(lo, cond)
2484
2485
}
2485
2486
@@ -2588,8 +2589,11 @@ impl<'a> Parser<'a> {
2588
2589
}
2589
2590
2590
2591
/// Parses the condition of a `if` or `while` expression.
2592
+
///
2593
+
/// The specified `edition` should be that of the whole `if` or `while` construct: the same
2594
+
/// span that we later decide the drop behaviour on (editions ..=2021 vs 2024..)
2591
2595
// 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