diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-06-16 09:47:07 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-06-16 09:52:04 +1000 |
| commit | be45f10a9c3b429eeef95dc24ebdd19cbccce0be (patch) | |
| tree | 1e7fccd75b585d4dbf89f8429cb958640c13c8bb | |
| parent | c9e97251adf538be8f7f34bfd3e02a4bed164cbd (diff) | |
| download | rust-be45f10a9c3b429eeef95dc24ebdd19cbccce0be.tar.gz rust-be45f10a9c3b429eeef95dc24ebdd19cbccce0be.zip | |
Inline and remove `{enter,exit}_attrs` functions.
They each have a single call site.
| -rw-r--r-- | compiler/rustc_lint/src/early.rs | 12 | ||||
| -rw-r--r-- | compiler/rustc_lint/src/late.rs | 16 |
2 files changed, 6 insertions, 22 deletions
diff --git a/compiler/rustc_lint/src/early.rs b/compiler/rustc_lint/src/early.rs index 2ab948958d0..5de35dc0856 100644 --- a/compiler/rustc_lint/src/early.rs +++ b/compiler/rustc_lint/src/early.rs @@ -63,20 +63,12 @@ impl<'a, T: EarlyLintPass> EarlyContextAndPass<'a, T> { let push = self.context.builder.push(attrs, is_crate_node, None); self.check_id(id); - self.enter_attrs(attrs); - f(self); - self.exit_attrs(attrs); - self.context.builder.pop(push); - } - - fn enter_attrs(&mut self, attrs: &'a [ast::Attribute]) { debug!("early context: enter_attrs({:?})", attrs); run_early_pass!(self, enter_lint_attrs, attrs); - } - - fn exit_attrs(&mut self, attrs: &'a [ast::Attribute]) { + f(self); debug!("early context: exit_attrs({:?})", attrs); run_early_pass!(self, exit_lint_attrs, attrs); + self.context.builder.pop(push); } } diff --git a/compiler/rustc_lint/src/late.rs b/compiler/rustc_lint/src/late.rs index e9b14b2693c..c1d8d76c975 100644 --- a/compiler/rustc_lint/src/late.rs +++ b/compiler/rustc_lint/src/late.rs @@ -59,9 +59,11 @@ impl<'tcx, T: LateLintPass<'tcx>> LateContextAndPass<'tcx, T> { let attrs = self.context.tcx.hir().attrs(id); let prev = self.context.last_node_with_lint_attrs; self.context.last_node_with_lint_attrs = id; - self.enter_attrs(attrs); + debug!("late context: enter_attrs({:?})", attrs); + lint_callback!(self, enter_lint_attrs, attrs); f(self); - self.exit_attrs(attrs); + debug!("late context: exit_attrs({:?})", attrs); + lint_callback!(self, exit_lint_attrs, attrs); self.context.last_node_with_lint_attrs = prev; } @@ -81,16 +83,6 @@ impl<'tcx, T: LateLintPass<'tcx>> LateContextAndPass<'tcx, T> { hir_visit::walk_mod(self, m, n); lint_callback!(self, check_mod_post, m, s, n); } - - fn enter_attrs(&mut self, attrs: &'tcx [ast::Attribute]) { - debug!("late context: enter_attrs({:?})", attrs); - lint_callback!(self, enter_lint_attrs, attrs); - } - - fn exit_attrs(&mut self, attrs: &'tcx [ast::Attribute]) { - debug!("late context: exit_attrs({:?})", attrs); - lint_callback!(self, exit_lint_attrs, attrs); - } } impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPass<'tcx, T> { |
