Auto merge of #98153 - nnethercote:fix-MissingDoc-quadratic-behaviour, r=cjgillot
Fix `MissingDoc` quadratic behaviour Best reviewed one commit at a time. r? `@cjgillot`
This commit is contained in:
commit
cdcc53b7dc
7 changed files with 16 additions and 36 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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> {
|
||||
|
@ -337,10 +329,8 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
|
|||
hir_visit::walk_path(self, p);
|
||||
}
|
||||
|
||||
fn visit_attribute(&mut self, hir_id: hir::HirId, attr: &'tcx ast::Attribute) {
|
||||
self.with_lint_attrs(hir_id, |cx| {
|
||||
lint_callback!(cx, check_attribute, attr);
|
||||
})
|
||||
fn visit_attribute(&mut self, attr: &'tcx ast::Attribute) {
|
||||
lint_callback!(self, check_attribute, attr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -402,7 +392,7 @@ fn late_lint_mod_pass<'tcx, T: LateLintPass<'tcx>>(
|
|||
// Visit the crate attributes
|
||||
if hir_id == hir::CRATE_HIR_ID {
|
||||
for attr in tcx.hir().attrs(hir::CRATE_HIR_ID).iter() {
|
||||
cx.visit_attribute(hir_id, attr)
|
||||
cx.visit_attribute(attr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue