diff options
| author | Jakub Beránek <berykubik@gmail.com> | 2025-04-09 19:22:32 +0200 |
|---|---|---|
| committer | Jakub Beránek <berykubik@gmail.com> | 2025-06-23 17:35:49 +0200 |
| commit | 6083850ba8544aef61fc54809174a6d83f2f00ec (patch) | |
| tree | ed7d3d1e877958732d905cdd5aa3bfe4f77674ee | |
| parent | 637bf919eb1117662267d1f187062719532505c1 (diff) | |
Skip `late_lint_mod_inner` if all built-in lints can be skipped
| -rw-r--r-- | compiler/rustc_lint/src/late.rs | 11 | ||||
| -rw-r--r-- | compiler/rustc_lint/src/passes.rs | 4 |
2 files changed, 12 insertions, 3 deletions
diff --git a/compiler/rustc_lint/src/late.rs b/compiler/rustc_lint/src/late.rs index 852bb01c096..34d18771b75 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 diff --git a/compiler/rustc_lint/src/passes.rs b/compiler/rustc_lint/src/passes.rs index b5756c0a187..bff7f0a9339 100644 --- a/compiler/rustc_lint/src/passes.rs +++ b/compiler/rustc_lint/src/passes.rs @@ -123,10 +123,10 @@ macro_rules! declare_combined_late_lint_pass { #[allow(rustc::lint_pass_impl_without_macro)] impl $crate::LintPass for $name { fn name(&self) -> &'static str { - panic!() + stringify!($name) } fn get_lints(&self) -> LintVec { - panic!() + $name::get_lints() } } ) |
