Skip to content

Commit cdcc53b

Browse files
committed
Auto merge of rust-lang#98153 - nnethercote:fix-MissingDoc-quadratic-behaviour, r=cjgillot
Fix `MissingDoc` quadratic behaviour Best reviewed one commit at a time. r? `@cjgillot`
2 parents 0182fd9 + be45f10 commit cdcc53b

File tree

7 files changed

+16
-36
lines changed

7 files changed

+16
-36
lines changed

compiler/rustc_hir/src/intravisit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ pub trait Visitor<'v>: Sized {
466466
fn visit_assoc_type_binding(&mut self, type_binding: &'v TypeBinding<'v>) {
467467
walk_assoc_type_binding(self, type_binding)
468468
}
469-
fn visit_attribute(&mut self, _id: HirId, _attr: &'v Attribute) {}
469+
fn visit_attribute(&mut self, _attr: &'v Attribute) {}
470470
fn visit_associated_item_kind(&mut self, kind: &'v AssocItemKind) {
471471
walk_associated_item_kind(self, kind);
472472
}

compiler/rustc_incremental/src/persist/dirty_clean.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
2222
use rustc_ast::{self as ast, Attribute, NestedMetaItem};
2323
use rustc_data_structures::fx::FxHashSet;
24-
use rustc_hir as hir;
2524
use rustc_hir::def_id::LocalDefId;
2625
use rustc_hir::intravisit;
2726
use rustc_hir::Node as HirNode;
@@ -473,7 +472,7 @@ impl<'tcx> intravisit::Visitor<'tcx> for FindAllAttrs<'tcx> {
473472
self.tcx.hir()
474473
}
475474

476-
fn visit_attribute(&mut self, _: hir::HirId, attr: &'tcx Attribute) {
475+
fn visit_attribute(&mut self, attr: &'tcx Attribute) {
477476
if self.is_active_attr(attr) {
478477
self.found_attrs.push(attr);
479478
}

compiler/rustc_lint/src/early.rs

+2-10
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,12 @@ impl<'a, T: EarlyLintPass> EarlyContextAndPass<'a, T> {
6363
let push = self.context.builder.push(attrs, is_crate_node, None);
6464

6565
self.check_id(id);
66-
self.enter_attrs(attrs);
67-
f(self);
68-
self.exit_attrs(attrs);
69-
self.context.builder.pop(push);
70-
}
71-
72-
fn enter_attrs(&mut self, attrs: &'a [ast::Attribute]) {
7366
debug!("early context: enter_attrs({:?})", attrs);
7467
run_early_pass!(self, enter_lint_attrs, attrs);
75-
}
76-
77-
fn exit_attrs(&mut self, attrs: &'a [ast::Attribute]) {
68+
f(self);
7869
debug!("early context: exit_attrs({:?})", attrs);
7970
run_early_pass!(self, exit_lint_attrs, attrs);
71+
self.context.builder.pop(push);
8072
}
8173
}
8274

compiler/rustc_lint/src/late.rs

+7-17
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,11 @@ impl<'tcx, T: LateLintPass<'tcx>> LateContextAndPass<'tcx, T> {
5959
let attrs = self.context.tcx.hir().attrs(id);
6060
let prev = self.context.last_node_with_lint_attrs;
6161
self.context.last_node_with_lint_attrs = id;
62-
self.enter_attrs(attrs);
62+
debug!("late context: enter_attrs({:?})", attrs);
63+
lint_callback!(self, enter_lint_attrs, attrs);
6364
f(self);
64-
self.exit_attrs(attrs);
65+
debug!("late context: exit_attrs({:?})", attrs);
66+
lint_callback!(self, exit_lint_attrs, attrs);
6567
self.context.last_node_with_lint_attrs = prev;
6668
}
6769

@@ -81,16 +83,6 @@ impl<'tcx, T: LateLintPass<'tcx>> LateContextAndPass<'tcx, T> {
8183
hir_visit::walk_mod(self, m, n);
8284
lint_callback!(self, check_mod_post, m, s, n);
8385
}
84-
85-
fn enter_attrs(&mut self, attrs: &'tcx [ast::Attribute]) {
86-
debug!("late context: enter_attrs({:?})", attrs);
87-
lint_callback!(self, enter_lint_attrs, attrs);
88-
}
89-
90-
fn exit_attrs(&mut self, attrs: &'tcx [ast::Attribute]) {
91-
debug!("late context: exit_attrs({:?})", attrs);
92-
lint_callback!(self, exit_lint_attrs, attrs);
93-
}
9486
}
9587

9688
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
337329
hir_visit::walk_path(self, p);
338330
}
339331

340-
fn visit_attribute(&mut self, hir_id: hir::HirId, attr: &'tcx ast::Attribute) {
341-
self.with_lint_attrs(hir_id, |cx| {
342-
lint_callback!(cx, check_attribute, attr);
343-
})
332+
fn visit_attribute(&mut self, attr: &'tcx ast::Attribute) {
333+
lint_callback!(self, check_attribute, attr);
344334
}
345335
}
346336

@@ -402,7 +392,7 @@ fn late_lint_mod_pass<'tcx, T: LateLintPass<'tcx>>(
402392
// Visit the crate attributes
403393
if hir_id == hir::CRATE_HIR_ID {
404394
for attr in tcx.hir().attrs(hir::CRATE_HIR_ID).iter() {
405-
cx.visit_attribute(hir_id, attr)
395+
cx.visit_attribute(attr)
406396
}
407397
}
408398
}

compiler/rustc_middle/src/hir/map/mod.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -577,12 +577,11 @@ impl<'hir> Map<'hir> {
577577
/// Walks the attributes in a crate.
578578
pub fn walk_attributes(self, visitor: &mut impl Visitor<'hir>) {
579579
let krate = self.krate();
580-
for (owner, info) in krate.owners.iter_enumerated() {
580+
for info in krate.owners.iter() {
581581
if let MaybeOwner::Owner(info) = info {
582-
for (local_id, attrs) in info.attrs.map.iter() {
583-
let id = HirId { owner, local_id: *local_id };
582+
for attrs in info.attrs.map.values() {
584583
for a in *attrs {
585-
visitor.visit_attribute(id, a)
584+
visitor.visit_attribute(a)
586585
}
587586
}
588587
}

compiler/rustc_passes/src/hir_stats.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
238238
hir_visit::walk_assoc_type_binding(self, type_binding)
239239
}
240240

241-
fn visit_attribute(&mut self, _: hir::HirId, attr: &'v ast::Attribute) {
241+
fn visit_attribute(&mut self, attr: &'v ast::Attribute) {
242242
self.record("Attribute", Id::Attr(attr.id), attr);
243243
}
244244
}

compiler/rustc_passes/src/lib_features.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl<'tcx> Visitor<'tcx> for LibFeatureCollector<'tcx> {
120120
self.tcx.hir()
121121
}
122122

123-
fn visit_attribute(&mut self, _: rustc_hir::HirId, attr: &'tcx Attribute) {
123+
fn visit_attribute(&mut self, attr: &'tcx Attribute) {
124124
if let Some((feature, stable, span)) = self.extract(attr) {
125125
self.collect_feature(feature, stable, span);
126126
}

0 commit comments

Comments
 (0)