&self.krate
}
- /// This is internally in the depedency tracking system.
+ /// This is used internally in the dependency tracking system.
/// Use the `krate` method to ensure your dependency on the
/// crate is tracked.
pub fn untracked_krate<'hir>(&'hir self) -> &'hir Crate {
}
}
Node::Variant(variant) => {
- let def_id = self.local_def_id_from_hir_id(variant.node.data.hir_id());
+ let def_id = self.local_def_id_from_hir_id(variant.node.id);
Some(Def::Variant(def_id))
}
- Node::StructCtor(variant) => {
- let def_id = self.local_def_id_from_hir_id(variant.hir_id());
- Some(Def::StructCtor(def_id, def::CtorKind::from_hir(variant)))
+ Node::Ctor(variant_data) => {
+ let ctor_of = match self.find(self.get_parent_node(node_id)) {
+ Some(Node::Item(..)) => def::CtorOf::Struct,
+ Some(Node::Variant(..)) => def::CtorOf::Variant,
+ _ => unreachable!(),
+ };
+ variant_data.ctor_hir_id()
+ .map(|hir_id| self.local_def_id_from_hir_id(hir_id))
+ .map(|def_id| Def::Ctor(def_id, ctor_of, def::CtorKind::from_hir(variant_data)))
}
Node::AnonConst(_) |
Node::Field(_) |
Node::AnonConst(_) => {
BodyOwnerKind::Const
}
- Node::Variant(&Spanned { node: VariantKind { data: VariantData::Tuple(..), .. }, .. }) |
- Node::StructCtor(..) |
+ Node::Ctor(..) |
Node::Item(&Item { node: ItemKind::Fn(..), .. }) |
Node::TraitItem(&TraitItem { node: TraitItemKind::Method(..), .. }) |
Node::ImplItem(&ImplItem { node: ImplItemKind::Method(..), .. }) => {
_ => bug!("struct ID bound to non-struct {}", self.hir_to_string(id))
}
}
- Some(Node::StructCtor(data)) => data,
Some(Node::Variant(variant)) => &variant.node.data,
+ Some(Node::Ctor(data)) => data,
_ => bug!("expected struct or variant, found {}", self.hir_to_string(id))
}
}
Node::Lifetime(lt) => lt.name.ident().name,
Node::GenericParam(param) => param.name.ident().name,
Node::Binding(&Pat { node: PatKind::Binding(_, _, l, _), .. }) => l.name,
- Node::StructCtor(_) => self.name(self.get_parent(id)),
+ Node::Ctor(..) => self.name(self.get_parent(id)),
_ => bug!("no name for {}", self.node_to_string(id))
}
}
Some(Node::Expr(ref e)) => Some(&*e.attrs),
Some(Node::Stmt(ref s)) => Some(s.node.attrs()),
Some(Node::GenericParam(param)) => Some(¶m.attrs[..]),
- // unit/tuple structs take the attributes straight from
- // the struct definition.
- Some(Node::StructCtor(_)) => return self.attrs(self.get_parent(id)),
+ // Unit/tuple structs/variants take the attributes straight from
+ // the struct/variant definition.
+ Some(Node::Ctor(..)) => return self.attrs(self.get_parent(id)),
_ => None
};
attrs.unwrap_or(&[])
Some(Node::Binding(pat)) => pat.span,
Some(Node::Pat(pat)) => pat.span,
Some(Node::Block(block)) => block.span,
- Some(Node::StructCtor(_)) => self.expect_item(self.get_parent(id)).span,
+ Some(Node::Ctor(..)) => match self.find(self.get_parent_node(id)) {
+ Some(Node::Item(item)) => item.span,
+ Some(Node::Variant(variant)) => variant.span,
+ _ => unreachable!(),
+ }
Some(Node::Lifetime(lifetime)) => lifetime.span,
Some(Node::GenericParam(param)) => param.span,
Some(Node::Visibility(&Spanned {
// these cases do not carry enough information in the
// hir_map to reconstruct their full structure for pretty
// printing.
- Node::StructCtor(_) => bug!("cannot print isolated StructCtor"),
+ Node::Ctor(..) => bug!("cannot print isolated Ctor"),
Node::Local(a) => self.print_local_decl(&a),
Node::MacroDef(_) => bug!("cannot print MacroDef"),
Node::Crate => bug!("cannot print Crate"),
Some(Node::Local(_)) => {
format!("local {}{}", map.node_to_pretty_string(id), id_str)
}
- Some(Node::StructCtor(_)) => {
- format!("struct_ctor {}{}", path_str(), id_str)
+ Some(Node::Ctor(..)) => {
+ format!("ctor {}{}", path_str(), id_str)
}
Some(Node::Lifetime(_)) => {
format!("lifetime {}{}", map.node_to_pretty_string(id), id_str)