about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2022-12-01 12:10:23 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2022-12-02 13:59:28 +1100
commit890c5ead2043f22c8d57d4758e0826cde896f059 (patch)
tree4a67e4d2d824a309d65ad3eb4251cb7b6b38c52f /compiler
parent99e9c1ddb7da43f8842619f05942a45f8d0f2642 (diff)
downloadrust-890c5ead2043f22c8d57d4758e0826cde896f059.tar.gz
rust-890c5ead2043f22c8d57d4758e0826cde896f059.zip
Merge `builtins` into `LateLintPassObjects`.
This avoids calling the `late_lint_{mod_pass,pass_crate}` twice.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_lint/src/late.rs20
1 files changed, 7 insertions, 13 deletions
diff --git a/compiler/rustc_lint/src/late.rs b/compiler/rustc_lint/src/late.rs
index d15afa20777..dd697bda8a6 100644
--- a/compiler/rustc_lint/src/late.rs
+++ b/compiler/rustc_lint/src/late.rs
@@ -358,19 +358,16 @@ fn late_lint_mod_pass<'tcx, T: LateLintPass<'tcx>>(
     }
 }
 
-pub fn late_lint_mod<'tcx, T: LateLintPass<'tcx>>(
+pub fn late_lint_mod<'tcx, T: LateLintPass<'tcx> + 'tcx>(
     tcx: TyCtxt<'tcx>,
     module_def_id: LocalDefId,
     builtin_lints: T,
 ) {
-    late_lint_mod_pass(tcx, module_def_id, builtin_lints);
-
     let mut passes: Vec<_> =
         unerased_lint_store(tcx).late_module_passes.iter().map(|pass| (pass)(tcx)).collect();
+    passes.push(Box::new(builtin_lints));
 
-    if !passes.is_empty() {
-        late_lint_mod_pass(tcx, module_def_id, LateLintPassObjects { lints: &mut passes[..] });
-    }
+    late_lint_mod_pass(tcx, module_def_id, LateLintPassObjects { lints: &mut passes[..] });
 }
 
 fn late_lint_pass_crate<'tcx, T: LateLintPass<'tcx>>(tcx: TyCtxt<'tcx>, pass: T) {
@@ -401,19 +398,16 @@ fn late_lint_pass_crate<'tcx, T: LateLintPass<'tcx>>(tcx: TyCtxt<'tcx>, pass: T)
     })
 }
 
-fn late_lint_crate<'tcx, T: LateLintPass<'tcx>>(tcx: TyCtxt<'tcx>, builtin_lints: T) {
+fn late_lint_crate<'tcx, T: LateLintPass<'tcx> + 'tcx>(tcx: TyCtxt<'tcx>, builtin_lints: T) {
     let mut passes =
         unerased_lint_store(tcx).late_passes.iter().map(|p| (p)(tcx)).collect::<Vec<_>>();
+    passes.push(Box::new(builtin_lints));
 
-    if !passes.is_empty() {
-        late_lint_pass_crate(tcx, LateLintPassObjects { lints: &mut passes[..] });
-    }
-
-    late_lint_pass_crate(tcx, builtin_lints);
+    late_lint_pass_crate(tcx, LateLintPassObjects { lints: &mut passes[..] });
 }
 
 /// Performs lint checking on a crate.
-pub fn check_crate<'tcx, T: LateLintPass<'tcx>>(
+pub fn check_crate<'tcx, T: LateLintPass<'tcx> + 'tcx>(
     tcx: TyCtxt<'tcx>,
     builtin_lints: impl FnOnce() -> T + Send,
 ) {