about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2022-12-07 14:58:48 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2022-12-07 19:29:31 +1100
commitd049be30cf3f53ecba2bde4ad5c832866965eb0a (patch)
tree98f814b77d4d55672aba2c6e806c49b709ba0049
parentb08fd6e8efec854d6a9c1a1486f04f8933e30795 (diff)
downloadrust-d049be30cf3f53ecba2bde4ad5c832866965eb0a.tar.gz
rust-d049be30cf3f53ecba2bde4ad5c832866965eb0a.zip
Split `EarlyContextAndPasses::check_id` in two.
-rw-r--r--compiler/rustc_lint/src/early.rs11
1 files 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 @@ impl<'a> EarlyContextAndPasses<'a> {
         }
     }
 
+    // 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 @@ impl<'a> EarlyContextAndPasses<'a> {
         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);