Skip to content

Commit 22a220a

Browse files
committed
Auto merge of #132666 - dingxiangfei2009:skip-if-let-rescope-lint, r=compiler-errors
Skip `if-let-rescope` lint unless requested by migration Tracked by #124085 Related to #131984 (comment) Given that `if-let-rescope` is a lint to be enabled globally by an edition migration, there is no point in extracting the precise lint level on the HIR expression. This mitigates the performance regression discovered by the earlier perf-run. cc `@Kobzol` `@rylev` `@traviscross` I propose a `rust-timer` run to measure how much performance that we can recover from the mitigation. 🙇
2 parents 99768c8 + 193fe5a commit 22a220a

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

compiler/rustc_lint/src/if_let_rescope.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_errors::{
99
use rustc_hir::{self as hir, HirIdSet};
1010
use rustc_macros::LintDiagnostic;
1111
use rustc_middle::ty::TyCtxt;
12-
use rustc_session::lint::{FutureIncompatibilityReason, Level};
12+
use rustc_session::lint::{FutureIncompatibilityReason, LintId};
1313
use rustc_session::{declare_lint, impl_lint_pass};
1414
use rustc_span::Span;
1515
use rustc_span::edition::Edition;
@@ -245,12 +245,12 @@ impl_lint_pass!(
245245

246246
impl<'tcx> LateLintPass<'tcx> for IfLetRescope {
247247
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>) {
248-
if expr.span.edition().at_least_rust_2024() {
249-
return;
250-
}
251-
if let (Level::Allow, _) = cx.tcx.lint_level_at_node(IF_LET_RESCOPE, expr.hir_id) {
248+
if expr.span.edition().at_least_rust_2024()
249+
|| cx.tcx.lints_that_dont_need_to_run(()).contains(&LintId::of(IF_LET_RESCOPE))
250+
{
252251
return;
253252
}
253+
254254
if let hir::ExprKind::Loop(block, _label, hir::LoopSource::While, _span) = expr.kind
255255
&& let Some(value) = block.expr
256256
&& let hir::ExprKind::If(cond, _conseq, _alt) = value.kind
@@ -290,7 +290,6 @@ struct IfLetRescopeLint {
290290
rewrite: Option<IfLetRescopeRewrite>,
291291
}
292292

293-
// #[derive(Subdiagnostic)]
294293
struct IfLetRescopeRewrite {
295294
match_heads: Vec<SingleArmMatchBegin>,
296295
consequent_heads: Vec<ConsequentRewrite>,

0 commit comments

Comments
 (0)