diff options
| author | bors <bors@rust-lang.org> | 2025-07-26 02:31:12 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-07-26 02:31:12 +0000 |
| commit | f32b23204a0efe2fe8383ed4be1a30b56c1bbf94 (patch) | |
| tree | 186b6bb0854e7cb8050ed919247c61fe4e06316e /compiler/rustc_lint/src/late.rs | |
| parent | 0dd07bd2165db70ffbe0b903635de26ca630bf20 (diff) | |
| parent | 6083850ba8544aef61fc54809174a6d83f2f00ec (diff) | |
| download | rust-f32b23204a0efe2fe8383ed4be1a30b56c1bbf94.tar.gz rust-f32b23204a0efe2fe8383ed4be1a30b56c1bbf94.zip | |
Auto merge of #139597 - Kobzol:lint-skip, r=BoxyUwU
Do not run per-module late lints if they can be all skipped We run ~70 late lints for all dependencies even if they use `--cap-lints=allow`, which seems wasteful. It looks like these lints are super fast (unlike early lints), but still. r? `@ghost`
Diffstat (limited to 'compiler/rustc_lint/src/late.rs')
| -rw-r--r-- | compiler/rustc_lint/src/late.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/compiler/rustc_lint/src/late.rs b/compiler/rustc_lint/src/late.rs index c681deea779..ccfba715a1b 100644 --- a/compiler/rustc_lint/src/late.rs +++ b/compiler/rustc_lint/src/late.rs @@ -356,7 +356,16 @@ pub fn late_lint_mod<'tcx, T: LateLintPass<'tcx> + 'tcx>( let store = unerased_lint_store(tcx.sess); if store.late_module_passes.is_empty() { - late_lint_mod_inner(tcx, module_def_id, context, builtin_lints); + // If all builtin lints can be skipped, there is no point in running `late_lint_mod_inner` + // at all. This happens often for dependencies built with `--cap-lints=allow`. + let dont_need_to_run = tcx.lints_that_dont_need_to_run(()); + let can_skip_lints = builtin_lints + .get_lints() + .iter() + .all(|lint| dont_need_to_run.contains(&LintId::of(lint))); + if !can_skip_lints { + late_lint_mod_inner(tcx, module_def_id, context, builtin_lints); + } } else { let builtin_lints = Box::new(builtin_lints) as Box<dyn LateLintPass<'tcx>>; let mut binding = store |
