Skip to content

Commit

Permalink
Split EarlyContextAndPasses::check_id in two.
Browse files Browse the repository at this point in the history
  • Loading branch information
nnethercote committed Dec 7, 2022
1 parent b08fd6e commit d049be3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions compiler/rustc_lint/src/early.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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.
Expand All @@ -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);
Expand Down

0 comments on commit d049be3

Please sign in to comment.