Skip to content

Commit f975d05

Browse files
committed
rename visit item-like methods
Signed-off-by: Miguel Guarniz <[email protected]>
1 parent 7e44078 commit f975d05

File tree

12 files changed

+23
-20
lines changed

12 files changed

+23
-20
lines changed

compiler/rustc_hir/src/intravisit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
//! - Example: Examine each expression to look for its type and do some check or other.
2020
//! - How: Implement `intravisit::Visitor` and override the `NestedFilter` type to
2121
//! `nested_filter::OnlyBodies` (and implement `nested_visit_map`), and use
22-
//! `tcx.hir().visit_all_item_likes(&mut visitor)`. Within your
22+
//! `tcx.hir().deep_visit_all_item_likes(&mut visitor)`. Within your
2323
//! `intravisit::Visitor` impl, implement methods like `visit_expr()` (don't forget to invoke
2424
//! `intravisit::walk_expr()` to keep walking the subparts).
2525
//! - Pro: Visitor methods for any kind of HIR node, not just item-like things.

compiler/rustc_incremental/src/assert_dep_graph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub fn assert_dep_graph(tcx: TyCtxt<'_>) {
7575
let mut visitor =
7676
IfThisChanged { tcx, if_this_changed: vec![], then_this_would_need: vec![] };
7777
visitor.process_attrs(hir::CRATE_HIR_ID);
78-
tcx.hir().visit_all_item_likes(&mut visitor);
78+
tcx.hir().deep_visit_all_item_likes(&mut visitor);
7979
(visitor.if_this_changed, visitor.then_this_would_need)
8080
};
8181

compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
452452
return;
453453
}
454454

455-
self.tcx.hir().visit_all_item_likes(self);
455+
self.tcx.hir().deep_visit_all_item_likes(self);
456456
}
457457

458458
fn encode_def_path_table(&mut self) {

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -606,14 +606,14 @@ impl<'hir> Map<'hir> {
606606
}
607607

608608
/// Visits all items in the crate in some deterministic (but
609-
/// unspecified) order. If you just need to process every item,
610-
/// but don't care about nesting, this method is the best choice.
609+
/// unspecified) order. If you need to process every item,
610+
/// and care about nesting -- usually because your algorithm
611+
/// follows lexical scoping rules -- then this method is the best choice.
612+
/// If you don't care about nesting, you should use the `tcx.hir_crate_items()` query
613+
/// or `items()` instead.
611614
///
612-
/// If you do care about nesting -- usually because your algorithm
613-
/// follows lexical scoping rules -- then you want a different
614-
/// approach. You should override `visit_nested_item` in your
615-
/// visitor and then call `intravisit::walk_crate` instead.
616-
pub fn visit_all_item_likes<V>(self, visitor: &mut V)
615+
/// Please see the notes in `intravisit.rs` for more information.
616+
pub fn deep_visit_all_item_likes<V>(self, visitor: &mut V)
617617
where
618618
V: Visitor<'hir>,
619619
{
@@ -646,7 +646,10 @@ impl<'hir> Map<'hir> {
646646
})
647647
}
648648

649-
pub fn visit_item_likes_in_module<V>(self, module: LocalDefId, visitor: &mut V)
649+
/// If you don't care about nesting, you should use the
650+
/// `tcx.hir_module_items()` query or `module_items()` instead.
651+
/// Please see notes in `deep_visit_all_item_likes`.
652+
pub fn deep_visit_item_likes_in_module<V>(self, module: LocalDefId, visitor: &mut V)
650653
where
651654
V: Visitor<'hir>,
652655
{

compiler/rustc_mir_transform/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ fn mir_keys(tcx: TyCtxt<'_>, (): ()) -> FxIndexSet<LocalDefId> {
170170
intravisit::walk_struct_def(self, v)
171171
}
172172
}
173-
tcx.hir().visit_all_item_likes(&mut GatherCtors { tcx, set: &mut set });
173+
tcx.hir().deep_visit_all_item_likes(&mut GatherCtors { tcx, set: &mut set });
174174

175175
set
176176
}

compiler/rustc_passes/src/check_attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2384,7 +2384,7 @@ fn check_non_exported_macro_for_invalid_attrs(tcx: TyCtxt<'_>, item: &Item<'_>)
23842384

23852385
fn check_mod_attrs(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
23862386
let check_attr_visitor = &mut CheckAttrVisitor { tcx };
2387-
tcx.hir().visit_item_likes_in_module(module_def_id, check_attr_visitor);
2387+
tcx.hir().deep_visit_item_likes_in_module(module_def_id, check_attr_visitor);
23882388
if module_def_id.is_top_level_module() {
23892389
check_attr_visitor.check_attributes(CRATE_HIR_ID, DUMMY_SP, Target::Mod, None);
23902390
check_invalid_crate_level_attr(tcx, tcx.hir().krate_attrs());

compiler/rustc_passes/src/intrinsicck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_target::asm::{InlineAsmRegOrRegClass, InlineAsmType};
1717
use rustc_target::spec::abi::Abi::RustIntrinsic;
1818

1919
fn check_mod_intrinsics(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
20-
tcx.hir().visit_item_likes_in_module(module_def_id, &mut ItemVisitor { tcx });
20+
tcx.hir().deep_visit_item_likes_in_module(module_def_id, &mut ItemVisitor { tcx });
2121
}
2222

2323
pub fn provide(providers: &mut Providers) {

compiler/rustc_passes/src/liveness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ fn live_node_kind_to_string(lnk: LiveNodeKind, tcx: TyCtxt<'_>) -> String {
140140
}
141141

142142
fn check_mod_liveness(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
143-
tcx.hir().visit_item_likes_in_module(module_def_id, &mut IrMaps::new(tcx));
143+
tcx.hir().deep_visit_item_likes_in_module(module_def_id, &mut IrMaps::new(tcx));
144144
}
145145

146146
pub fn provide(providers: &mut Providers) {

compiler/rustc_passes/src/loops.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ struct CheckLoopVisitor<'a, 'hir> {
3131
}
3232

3333
fn check_mod_loops(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
34-
tcx.hir().visit_item_likes_in_module(
34+
tcx.hir().deep_visit_item_likes_in_module(
3535
module_def_id,
3636
&mut CheckLoopVisitor { sess: &tcx.sess, hir_map: tcx.hir(), cx: Normal },
3737
);

compiler/rustc_passes/src/naked_functions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rustc_span::Span;
1414
use rustc_target::spec::abi::Abi;
1515

1616
fn check_mod_naked_functions(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
17-
tcx.hir().visit_item_likes_in_module(module_def_id, &mut CheckNakedFunctions { tcx });
17+
tcx.hir().deep_visit_item_likes_in_module(module_def_id, &mut CheckNakedFunctions { tcx });
1818
}
1919

2020
crate fn provide(providers: &mut Providers) {

compiler/rustc_passes/src/stability.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ fn stability_index(tcx: TyCtxt<'_>, (): ()) -> Index {
661661
/// Cross-references the feature names of unstable APIs with enabled
662662
/// features and possibly prints errors.
663663
fn check_mod_unstable_api_usage(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
664-
tcx.hir().visit_item_likes_in_module(module_def_id, &mut Checker { tcx });
664+
tcx.hir().deep_visit_item_likes_in_module(module_def_id, &mut Checker { tcx });
665665
}
666666

667667
pub(crate) fn provide(providers: &mut Providers) {
@@ -837,7 +837,7 @@ pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) {
837837
let mut missing = MissingStabilityAnnotations { tcx, access_levels };
838838
missing.check_missing_stability(CRATE_DEF_ID, tcx.hir().span(CRATE_HIR_ID));
839839
tcx.hir().walk_toplevel_module(&mut missing);
840-
tcx.hir().visit_all_item_likes(&mut missing);
840+
tcx.hir().deep_visit_all_item_likes(&mut missing);
841841
}
842842

843843
let declared_lang_features = &tcx.features().declared_lang_features;

compiler/rustc_typeck/src/collect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ struct OnlySelfBounds(bool);
5959
// Main entry point
6060

6161
fn collect_mod_item_types(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
62-
tcx.hir().visit_item_likes_in_module(module_def_id, &mut CollectItemTypesVisitor { tcx });
62+
tcx.hir().deep_visit_item_likes_in_module(module_def_id, &mut CollectItemTypesVisitor { tcx });
6363
}
6464

6565
pub fn provide(providers: &mut Providers) {

0 commit comments

Comments
 (0)