From: Nicholas Nethercote Date: Thu, 1 Dec 2022 01:18:02 +0000 (+1100) Subject: Inline and remove `late_lint_mod_pass`. X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=0e4f55d63f84d86f856aa60786823e72083f40eb;p=rust.git Inline and remove `late_lint_mod_pass`. It has a single call site. --- diff --git a/compiler/rustc_lint/src/late.rs b/compiler/rustc_lint/src/late.rs index dd697bda8a6..6a22c87cf56 100644 --- a/compiler/rustc_lint/src/late.rs +++ b/compiler/rustc_lint/src/late.rs @@ -326,25 +326,28 @@ impl<$hir> LateLintPass<$hir> for LateLintPassObjects<'_, $hir> { crate::late_lint_methods!(late_lint_pass_impl, [], ['tcx]); -fn late_lint_mod_pass<'tcx, T: LateLintPass<'tcx>>( +pub fn late_lint_mod<'tcx, T: LateLintPass<'tcx> + 'tcx>( tcx: TyCtxt<'tcx>, module_def_id: LocalDefId, - pass: T, + builtin_lints: T, ) { - let effective_visibilities = &tcx.effective_visibilities(()); - let context = LateContext { tcx, enclosing_body: None, cached_typeck_results: Cell::new(None), param_env: ty::ParamEnv::empty(), - effective_visibilities, + effective_visibilities: &tcx.effective_visibilities(()), lint_store: unerased_lint_store(tcx), last_node_with_lint_attrs: tcx.hir().local_def_id_to_hir_id(module_def_id), generics: None, only_module: true, }; + let mut passes: Vec<_> = + unerased_lint_store(tcx).late_module_passes.iter().map(|pass| (pass)(tcx)).collect(); + passes.push(Box::new(builtin_lints)); + let pass = LateLintPassObjects { lints: &mut passes[..] }; + let mut cx = LateContextAndPass { context, pass }; let (module, _span, hir_id) = tcx.hir().get_module(module_def_id); @@ -358,18 +361,6 @@ fn late_lint_mod_pass<'tcx, T: LateLintPass<'tcx>>( } } -pub fn late_lint_mod<'tcx, T: LateLintPass<'tcx> + 'tcx>( - tcx: TyCtxt<'tcx>, - module_def_id: LocalDefId, - builtin_lints: T, -) { - let mut passes: Vec<_> = - unerased_lint_store(tcx).late_module_passes.iter().map(|pass| (pass)(tcx)).collect(); - passes.push(Box::new(builtin_lints)); - - 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) { let effective_visibilities = &tcx.effective_visibilities(());