pub map: Vec<MapEntry<'ast>>,
/// The parent of this node
pub parent_node: NodeId,
+ /// If true, completely ignore nested items. We set this when loading
+ /// HIR from metadata, since in that case we only want the HIR for
+ /// one specific item (and not the ones nested inside of it).
+ pub ignore_nested_items: bool
}
impl<'ast> NodeCollector<'ast> {
krate: krate,
map: vec![],
parent_node: CRATE_NODE_ID,
+ ignore_nested_items: false
};
collector.insert_entry(CRATE_NODE_ID, RootCrate);
krate: krate,
map: map,
parent_node: parent_node,
+ ignore_nested_items: true
};
assert_eq!(parent_def_path.krate, parent_def_id.krate);
/// their outer items.
fn visit_nested_item(&mut self, item: ItemId) {
debug!("visit_nested_item: {:?}", item);
- self.visit_item(self.krate.item(item.id))
+ if !self.ignore_nested_items {
+ self.visit_item(self.krate.item(item.id))
+ }
}
fn visit_item(&mut self, i: &'ast Item) {
// We walk the HIR rather than the AST when reading items from metadata.
impl<'ast> intravisit::Visitor<'ast> for DefCollector<'ast> {
- /// Because we want to track parent items and so forth, enable
- /// deep walking so that we walk nested items in the context of
- /// their outer items.
- fn visit_nested_item(&mut self, item_id: hir::ItemId) {
- debug!("visit_nested_item: {:?}", item_id);
- let item = self.hir_crate.unwrap().item(item_id.id);
- self.visit_item(item)
- }
-
fn visit_item(&mut self, i: &'ast hir::Item) {
debug!("visit_item: {:?}", i);
pub const C1: usize = 1;
pub const C2: atomic::AtomicUsize = atomic::AtomicUsize::new(0);
-pub const C3: fn() = foo;
+pub const C3: fn() = { fn foo() {} foo };
pub const C4: usize = C1 * C1 + C1 / C1;
pub const C5: &'static usize = &C4;
pub static S1: usize = 3;
pub static S2: atomic::AtomicUsize = atomic::AtomicUsize::new(0);
-fn foo() {}