rename visit item-like methods
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
This commit is contained in:
parent
7e44078e9a
commit
f975d05116
12 changed files with 23 additions and 20 deletions
|
@ -19,7 +19,7 @@
|
||||||
//! - Example: Examine each expression to look for its type and do some check or other.
|
//! - Example: Examine each expression to look for its type and do some check or other.
|
||||||
//! - How: Implement `intravisit::Visitor` and override the `NestedFilter` type to
|
//! - How: Implement `intravisit::Visitor` and override the `NestedFilter` type to
|
||||||
//! `nested_filter::OnlyBodies` (and implement `nested_visit_map`), and use
|
//! `nested_filter::OnlyBodies` (and implement `nested_visit_map`), and use
|
||||||
//! `tcx.hir().visit_all_item_likes(&mut visitor)`. Within your
|
//! `tcx.hir().deep_visit_all_item_likes(&mut visitor)`. Within your
|
||||||
//! `intravisit::Visitor` impl, implement methods like `visit_expr()` (don't forget to invoke
|
//! `intravisit::Visitor` impl, implement methods like `visit_expr()` (don't forget to invoke
|
||||||
//! `intravisit::walk_expr()` to keep walking the subparts).
|
//! `intravisit::walk_expr()` to keep walking the subparts).
|
||||||
//! - Pro: Visitor methods for any kind of HIR node, not just item-like things.
|
//! - Pro: Visitor methods for any kind of HIR node, not just item-like things.
|
||||||
|
|
|
@ -75,7 +75,7 @@ pub fn assert_dep_graph(tcx: TyCtxt<'_>) {
|
||||||
let mut visitor =
|
let mut visitor =
|
||||||
IfThisChanged { tcx, if_this_changed: vec![], then_this_would_need: vec![] };
|
IfThisChanged { tcx, if_this_changed: vec![], then_this_would_need: vec![] };
|
||||||
visitor.process_attrs(hir::CRATE_HIR_ID);
|
visitor.process_attrs(hir::CRATE_HIR_ID);
|
||||||
tcx.hir().visit_all_item_likes(&mut visitor);
|
tcx.hir().deep_visit_all_item_likes(&mut visitor);
|
||||||
(visitor.if_this_changed, visitor.then_this_would_need)
|
(visitor.if_this_changed, visitor.then_this_would_need)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -452,7 +452,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.tcx.hir().visit_all_item_likes(self);
|
self.tcx.hir().deep_visit_all_item_likes(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn encode_def_path_table(&mut self) {
|
fn encode_def_path_table(&mut self) {
|
||||||
|
|
|
@ -606,14 +606,14 @@ impl<'hir> Map<'hir> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Visits all items in the crate in some deterministic (but
|
/// Visits all items in the crate in some deterministic (but
|
||||||
/// unspecified) order. If you just need to process every item,
|
/// unspecified) order. If you need to process every item,
|
||||||
/// but don't care about nesting, this method is the best choice.
|
/// and care about nesting -- usually because your algorithm
|
||||||
|
/// follows lexical scoping rules -- then this method is the best choice.
|
||||||
|
/// If you don't care about nesting, you should use the `tcx.hir_crate_items()` query
|
||||||
|
/// or `items()` instead.
|
||||||
///
|
///
|
||||||
/// If you do care about nesting -- usually because your algorithm
|
/// Please see the notes in `intravisit.rs` for more information.
|
||||||
/// follows lexical scoping rules -- then you want a different
|
pub fn deep_visit_all_item_likes<V>(self, visitor: &mut V)
|
||||||
/// approach. You should override `visit_nested_item` in your
|
|
||||||
/// visitor and then call `intravisit::walk_crate` instead.
|
|
||||||
pub fn visit_all_item_likes<V>(self, visitor: &mut V)
|
|
||||||
where
|
where
|
||||||
V: Visitor<'hir>,
|
V: Visitor<'hir>,
|
||||||
{
|
{
|
||||||
|
@ -646,7 +646,10 @@ impl<'hir> Map<'hir> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn visit_item_likes_in_module<V>(self, module: LocalDefId, visitor: &mut V)
|
/// If you don't care about nesting, you should use the
|
||||||
|
/// `tcx.hir_module_items()` query or `module_items()` instead.
|
||||||
|
/// Please see notes in `deep_visit_all_item_likes`.
|
||||||
|
pub fn deep_visit_item_likes_in_module<V>(self, module: LocalDefId, visitor: &mut V)
|
||||||
where
|
where
|
||||||
V: Visitor<'hir>,
|
V: Visitor<'hir>,
|
||||||
{
|
{
|
||||||
|
|
|
@ -170,7 +170,7 @@ fn mir_keys(tcx: TyCtxt<'_>, (): ()) -> FxIndexSet<LocalDefId> {
|
||||||
intravisit::walk_struct_def(self, v)
|
intravisit::walk_struct_def(self, v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tcx.hir().visit_all_item_likes(&mut GatherCtors { tcx, set: &mut set });
|
tcx.hir().deep_visit_all_item_likes(&mut GatherCtors { tcx, set: &mut set });
|
||||||
|
|
||||||
set
|
set
|
||||||
}
|
}
|
||||||
|
|
|
@ -2384,7 +2384,7 @@ fn check_non_exported_macro_for_invalid_attrs(tcx: TyCtxt<'_>, item: &Item<'_>)
|
||||||
|
|
||||||
fn check_mod_attrs(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
|
fn check_mod_attrs(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
|
||||||
let check_attr_visitor = &mut CheckAttrVisitor { tcx };
|
let check_attr_visitor = &mut CheckAttrVisitor { tcx };
|
||||||
tcx.hir().visit_item_likes_in_module(module_def_id, check_attr_visitor);
|
tcx.hir().deep_visit_item_likes_in_module(module_def_id, check_attr_visitor);
|
||||||
if module_def_id.is_top_level_module() {
|
if module_def_id.is_top_level_module() {
|
||||||
check_attr_visitor.check_attributes(CRATE_HIR_ID, DUMMY_SP, Target::Mod, None);
|
check_attr_visitor.check_attributes(CRATE_HIR_ID, DUMMY_SP, Target::Mod, None);
|
||||||
check_invalid_crate_level_attr(tcx, tcx.hir().krate_attrs());
|
check_invalid_crate_level_attr(tcx, tcx.hir().krate_attrs());
|
||||||
|
|
|
@ -17,7 +17,7 @@ use rustc_target::asm::{InlineAsmRegOrRegClass, InlineAsmType};
|
||||||
use rustc_target::spec::abi::Abi::RustIntrinsic;
|
use rustc_target::spec::abi::Abi::RustIntrinsic;
|
||||||
|
|
||||||
fn check_mod_intrinsics(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
|
fn check_mod_intrinsics(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
|
||||||
tcx.hir().visit_item_likes_in_module(module_def_id, &mut ItemVisitor { tcx });
|
tcx.hir().deep_visit_item_likes_in_module(module_def_id, &mut ItemVisitor { tcx });
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn provide(providers: &mut Providers) {
|
pub fn provide(providers: &mut Providers) {
|
||||||
|
|
|
@ -140,7 +140,7 @@ fn live_node_kind_to_string(lnk: LiveNodeKind, tcx: TyCtxt<'_>) -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_mod_liveness(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
|
fn check_mod_liveness(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
|
||||||
tcx.hir().visit_item_likes_in_module(module_def_id, &mut IrMaps::new(tcx));
|
tcx.hir().deep_visit_item_likes_in_module(module_def_id, &mut IrMaps::new(tcx));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn provide(providers: &mut Providers) {
|
pub fn provide(providers: &mut Providers) {
|
||||||
|
|
|
@ -31,7 +31,7 @@ struct CheckLoopVisitor<'a, 'hir> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_mod_loops(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
|
fn check_mod_loops(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
|
||||||
tcx.hir().visit_item_likes_in_module(
|
tcx.hir().deep_visit_item_likes_in_module(
|
||||||
module_def_id,
|
module_def_id,
|
||||||
&mut CheckLoopVisitor { sess: &tcx.sess, hir_map: tcx.hir(), cx: Normal },
|
&mut CheckLoopVisitor { sess: &tcx.sess, hir_map: tcx.hir(), cx: Normal },
|
||||||
);
|
);
|
||||||
|
|
|
@ -14,7 +14,7 @@ use rustc_span::Span;
|
||||||
use rustc_target::spec::abi::Abi;
|
use rustc_target::spec::abi::Abi;
|
||||||
|
|
||||||
fn check_mod_naked_functions(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
|
fn check_mod_naked_functions(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
|
||||||
tcx.hir().visit_item_likes_in_module(module_def_id, &mut CheckNakedFunctions { tcx });
|
tcx.hir().deep_visit_item_likes_in_module(module_def_id, &mut CheckNakedFunctions { tcx });
|
||||||
}
|
}
|
||||||
|
|
||||||
crate fn provide(providers: &mut Providers) {
|
crate fn provide(providers: &mut Providers) {
|
||||||
|
|
|
@ -661,7 +661,7 @@ fn stability_index(tcx: TyCtxt<'_>, (): ()) -> Index {
|
||||||
/// Cross-references the feature names of unstable APIs with enabled
|
/// Cross-references the feature names of unstable APIs with enabled
|
||||||
/// features and possibly prints errors.
|
/// features and possibly prints errors.
|
||||||
fn check_mod_unstable_api_usage(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
|
fn check_mod_unstable_api_usage(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
|
||||||
tcx.hir().visit_item_likes_in_module(module_def_id, &mut Checker { tcx });
|
tcx.hir().deep_visit_item_likes_in_module(module_def_id, &mut Checker { tcx });
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn provide(providers: &mut Providers) {
|
pub(crate) fn provide(providers: &mut Providers) {
|
||||||
|
@ -837,7 +837,7 @@ pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) {
|
||||||
let mut missing = MissingStabilityAnnotations { tcx, access_levels };
|
let mut missing = MissingStabilityAnnotations { tcx, access_levels };
|
||||||
missing.check_missing_stability(CRATE_DEF_ID, tcx.hir().span(CRATE_HIR_ID));
|
missing.check_missing_stability(CRATE_DEF_ID, tcx.hir().span(CRATE_HIR_ID));
|
||||||
tcx.hir().walk_toplevel_module(&mut missing);
|
tcx.hir().walk_toplevel_module(&mut missing);
|
||||||
tcx.hir().visit_all_item_likes(&mut missing);
|
tcx.hir().deep_visit_all_item_likes(&mut missing);
|
||||||
}
|
}
|
||||||
|
|
||||||
let declared_lang_features = &tcx.features().declared_lang_features;
|
let declared_lang_features = &tcx.features().declared_lang_features;
|
||||||
|
|
|
@ -59,7 +59,7 @@ struct OnlySelfBounds(bool);
|
||||||
// Main entry point
|
// Main entry point
|
||||||
|
|
||||||
fn collect_mod_item_types(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
|
fn collect_mod_item_types(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
|
||||||
tcx.hir().visit_item_likes_in_module(module_def_id, &mut CollectItemTypesVisitor { tcx });
|
tcx.hir().deep_visit_item_likes_in_module(module_def_id, &mut CollectItemTypesVisitor { tcx });
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn provide(providers: &mut Providers) {
|
pub fn provide(providers: &mut Providers) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue