Skip to content

Commit e59d9b1

Browse files
committed
Avoid a collection and iteration on empty passes
1 parent 8fb67fb commit e59d9b1

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

compiler/rustc_lint/src/late.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -364,14 +364,14 @@ pub fn late_lint_mod<'tcx, T: LateLintPass<'tcx> + 'tcx>(
364364
// Note: `passes` is often empty. In that case, it's faster to run
365365
// `builtin_lints` directly rather than bundling it up into the
366366
// `RuntimeCombinedLateLintPass`.
367-
let mut passes: Vec<_> = unerased_lint_store(tcx.sess)
368-
.late_module_passes
369-
.iter()
370-
.map(|mk_pass| (mk_pass)(tcx))
371-
.collect();
372-
if passes.is_empty() {
367+
let late_module_passes = &unerased_lint_store(tcx.sess).late_module_passes;
368+
if late_module_passes.is_empty() {
373369
late_lint_mod_inner(tcx, module_def_id, context, builtin_lints);
374370
} else {
371+
let mut passes: Vec<_> = late_module_passes
372+
.iter()
373+
.map(|mk_pass| (mk_pass)(tcx))
374+
.collect();
375375
passes.push(Box::new(builtin_lints));
376376
let pass = RuntimeCombinedLateLintPass { passes: &mut passes[..] };
377377
late_lint_mod_inner(tcx, module_def_id, context, pass);

0 commit comments

Comments
 (0)