From d049be30cf3f53ecba2bde4ad5c832866965eb0a Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 7 Dec 2022 14:58:48 +1100 Subject: [PATCH] Split `EarlyContextAndPasses::check_id` in two. --- compiler/rustc_lint/src/early.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_lint/src/early.rs b/compiler/rustc_lint/src/early.rs index 52363b0be2d..5d81370c35a 100644 --- a/compiler/rustc_lint/src/early.rs +++ b/compiler/rustc_lint/src/early.rs @@ -37,7 +37,9 @@ pub struct EarlyContextAndPasses<'a> { } impl<'a> EarlyContextAndPasses<'a> { - fn check_id(&mut self, id: ast::NodeId) { + // This always-inlined function is for the hot call site. + #[inline(always)] + fn inlined_check_id(&mut self, id: ast::NodeId) { for early_lint in self.context.buffered.take(id) { let BufferedEarlyLint { span, msg, node_id: _, lint_id, diagnostic } = early_lint; self.context.lookup_with_diagnostics( @@ -50,6 +52,11 @@ fn check_id(&mut self, id: ast::NodeId) { } } + // This non-inlined function is for the cold call sites. + fn check_id(&mut self, id: ast::NodeId) { + self.inlined_check_id(id) + } + /// Merge the lints specified by any lint attributes into the /// current lint context, call the provided function, then reset the /// lints in effect to their previous state. @@ -61,7 +68,7 @@ fn with_lint_attrs(&mut self, id: ast::NodeId, attrs: &'a [ast::Attribute], f debug!(?id); let push = self.context.builder.push(attrs, is_crate_node, None); - self.check_id(id); + self.inlined_check_id(id); debug!("early context: enter_attrs({:?})", attrs); run_early_passes!(self, enter_lint_attrs, attrs); f(self); -- 2.44.0