Skip to content

Commit 3c4fb44

Browse files
committed
Skip late_lint_mod_inner if all built-in lints can be skipped
1 parent 87dfaf5 commit 3c4fb44

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

compiler/rustc_lint/src/late.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,14 @@ pub fn late_lint_mod<'tcx, T: LateLintPass<'tcx> + 'tcx>(
356356
let store = unerased_lint_store(tcx.sess);
357357

358358
if store.late_module_passes.is_empty() {
359-
late_lint_mod_inner(tcx, module_def_id, context, builtin_lints);
359+
// If all builtin lints can be skipped, there is no point in running `late_lint_mod_inner`
360+
// at all. This happens often for dependencies built with `--cap-lints=allow`.
361+
let dont_need_to_run = tcx.lints_that_dont_need_to_run(());
362+
let can_skip_lints =
363+
builtin_lints.get_lints().iter().all(|l| dont_need_to_run.contains(&LintId::of(l)));
364+
if !can_skip_lints {
365+
late_lint_mod_inner(tcx, module_def_id, context, builtin_lints);
366+
}
360367
} else {
361368
let builtin_lints = Box::new(builtin_lints) as Box<dyn LateLintPass<'tcx>>;
362369
let mut binding = store

compiler/rustc_lint/src/passes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ macro_rules! declare_combined_late_lint_pass {
123123
#[allow(rustc::lint_pass_impl_without_macro)]
124124
impl $crate::LintPass for $name {
125125
fn name(&self) -> &'static str {
126-
panic!()
126+
stringify!($name)
127127
}
128128
fn get_lints(&self) -> LintVec {
129-
panic!()
129+
$name::get_lints()
130130
}
131131
}
132132
)

0 commit comments

Comments
 (0)