[−][src]Trait rustc::hir::itemlikevisit::ItemLikeVisitor
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
The "item-like visitor" visitor defines only the top-level methods
that can be invoked by Crate::visit_all_item_likes()
. Whether
this trait is the right one to implement will depend on the
overall pattern you need. Here are the three available patterns,
in roughly the order of desirability:
- Shallow visit: Get a simple callback for every item (or item-like thing) in the HIR.
- Example: find all items with a
#[foo]
attribute on them. - How: Implement
ItemLikeVisitor
and calltcx.hir.krate().visit_all_item_likes()
. - Pro: Efficient; just walks the lists of item-like things, not the nodes themselves.
- Con: Don't get information about nesting
- Con: Don't have methods for specific bits of HIR, like "on every expr, do this".
- Example: find all items with a
- Deep visit: Want to scan for specific kinds of HIR nodes within
an item, but don't care about how item-like things are nested
within one another.
- Example: Examine each expression to look for its type and do some check or other.
- How: Implement
intravisit::Visitor
and usetcx.hir.krate().visit_all_item_likes(visitor.as_deep_visitor())
. Within yourintravisit::Visitor
impl, implement methods likevisit_expr()
; don't forget to invokeintravisit::walk_visit_expr()
to keep walking the subparts. - Pro: Visitor methods for any kind of HIR node, not just item-like things.
- Pro: Integrates well into dependency tracking.
- Con: Don't get information about nesting between items
- Nested visit: Want to visit the whole HIR and you care about the nesting between
item-like things.
- Example: Lifetime resolution, which wants to bring lifetimes declared on the impl into scope while visiting the impl-items, and then back out again.
- How: Implement
intravisit::Visitor
and override thenested_visit_map()
methods to returnNestedVisitorMap::All
. Walk your crate withintravisit::walk_crate()
invoked ontcx.hir.krate()
. - Pro: Visitor methods for any kind of HIR node, not just item-like things.
- Pro: Preserves nesting information
- Con: Does not integrate well into dependency tracking.
Note: the methods of ItemLikeVisitor
intentionally have no
defaults, so that as we expand the list of item-like things, we
revisit the various visitors to see if they need to change. This
is harder to do with intravisit::Visitor
, so when you add a new
visit_nested_foo()
method, it is recommended that you search for
existing fn visit_nested
methods to see where changes are
needed.
Required Methods
fn visit_item(&mut self, item: &'hir Item)
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn visit_trait_item(&mut self, trait_item: &'hir TraitItem)
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn visit_impl_item(&mut self, impl_item: &'hir ImplItem)
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Implementors
impl<'a, 'hir: 'a> ItemLikeVisitor<'hir> for OuterVisitor<'a, 'hir>
[src]
impl<'a, 'hir: 'a> ItemLikeVisitor<'hir> for OuterVisitor<'a, 'hir>
fn visit_item(&mut self, i: &'hir Item)
[src]
fn visit_item(&mut self, i: &'hir Item)
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn visit_trait_item(&mut self, i: &'hir TraitItem)
[src]
fn visit_trait_item(&mut self, i: &'hir TraitItem)
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn visit_impl_item(&mut self, i: &'hir ImplItem)
[src]
fn visit_impl_item(&mut self, i: &'hir ImplItem)
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
impl<'a, 'tcx> ItemLikeVisitor<'tcx> for EntryContext<'a, 'tcx>
[src]
impl<'a, 'tcx> ItemLikeVisitor<'tcx> for EntryContext<'a, 'tcx>
fn visit_item(&mut self, item: &'tcx Item)
[src]
fn visit_item(&mut self, item: &'tcx Item)
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn visit_trait_item(&mut self, _trait_item: &'tcx TraitItem)
[src]
fn visit_trait_item(&mut self, _trait_item: &'tcx TraitItem)
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn visit_impl_item(&mut self, _impl_item: &'tcx ImplItem)
[src]
fn visit_impl_item(&mut self, _impl_item: &'tcx ImplItem)
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
impl<'a, 'tcx: 'a> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a, 'tcx>
[src]
impl<'a, 'tcx: 'a> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a, 'tcx>
fn visit_item(&mut self, item: &Item)
[src]
fn visit_item(&mut self, item: &Item)
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn visit_trait_item(&mut self, _trait_item: &TraitItem)
[src]
fn visit_trait_item(&mut self, _trait_item: &TraitItem)
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn visit_impl_item(&mut self, _impl_item: &ImplItem)
[src]
fn visit_impl_item(&mut self, _impl_item: &ImplItem)
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
impl<'a, 'v, 'tcx> ItemLikeVisitor<'v> for LanguageItemCollector<'a, 'tcx>
[src]
impl<'a, 'v, 'tcx> ItemLikeVisitor<'v> for LanguageItemCollector<'a, 'tcx>
fn visit_item(&mut self, item: &Item)
[src]
fn visit_item(&mut self, item: &Item)
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn visit_trait_item(&mut self, _trait_item: &TraitItem)
[src]
fn visit_trait_item(&mut self, _trait_item: &TraitItem)
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn visit_impl_item(&mut self, _impl_item: &ImplItem)
[src]
fn visit_impl_item(&mut self, _impl_item: &ImplItem)
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
impl<'v, 'hir, V> ItemLikeVisitor<'hir> for DeepVisitor<'v, V> where
V: Visitor<'hir>,
[src]
impl<'v, 'hir, V> ItemLikeVisitor<'hir> for DeepVisitor<'v, V> where
V: Visitor<'hir>,
fn visit_item(&mut self, item: &'hir Item)
[src]
fn visit_item(&mut self, item: &'hir Item)
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn visit_trait_item(&mut self, trait_item: &'hir TraitItem)
[src]
fn visit_trait_item(&mut self, trait_item: &'hir TraitItem)
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn visit_impl_item(&mut self, impl_item: &'hir ImplItem)
[src]
fn visit_impl_item(&mut self, impl_item: &'hir ImplItem)
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
impl<'v, 'k, 'tcx> ItemLikeVisitor<'v> for LifeSeeder<'k, 'tcx>
[src]
impl<'v, 'k, 'tcx> ItemLikeVisitor<'v> for LifeSeeder<'k, 'tcx>
fn visit_item(&mut self, item: &Item)
[src]
fn visit_item(&mut self, item: &Item)
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn visit_trait_item(&mut self, _item: &TraitItem)
[src]
fn visit_trait_item(&mut self, _item: &TraitItem)
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn visit_impl_item(&mut self, _item: &ImplItem)
[src]
fn visit_impl_item(&mut self, _item: &ImplItem)
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?