self.tcx.definitions.def_path(def_id)
}
- // FIXME(eddyb) this function can and should return `LocalDefId`.
#[inline]
- pub fn local_def_id_from_node_id(&self, node: NodeId) -> DefId {
- self.opt_local_def_id_from_node_id(node)
- .unwrap_or_else(|| {
- let hir_id = self.node_id_to_hir_id(node);
- bug!(
- "local_def_id_from_node_id: no entry for `{}`, which has a map of `{:?}`",
- node,
- self.find_entry(hir_id)
- )
- })
- .to_def_id()
+ pub fn local_def_id_from_node_id(&self, node: NodeId) -> LocalDefId {
+ self.opt_local_def_id_from_node_id(node).unwrap_or_else(|| {
+ let hir_id = self.node_id_to_hir_id(node);
+ bug!(
+ "local_def_id_from_node_id: no entry for `{}`, which has a map of `{:?}`",
+ node,
+ self.find_entry(hir_id)
+ )
+ })
}
// FIXME(eddyb) this function can and should return `LocalDefId`.
where
F: FnOnce(&mut Self),
{
- let item_def_id = self.tcx.hir().local_def_id_from_node_id(item_id);
+ let item_def_id = self.tcx.hir().local_def_id_from_node_id(item_id).to_def_id();
let tables = if self.tcx.has_typeck_tables(item_def_id) {
self.tcx.typeck_tables_of(item_def_id)
vis: ast::Visibility,
attrs: &'l [Attribute],
) {
- let qualname =
- format!("::{}", self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(id)));
+ let qualname = format!(
+ "::{}",
+ self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(id).to_def_id())
+ );
if !self.span.filter_generated(ident.span) {
let sig = sig::assoc_const_signature(id, ident.name, typ, expr, &self.save_ctxt);
let name = item.ident.to_string();
let qualname = format!(
"::{}",
- self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id))
+ self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id).to_def_id())
);
let kind = match item.kind {
}
v.process_generic_params(generics, "", item.id);
for impl_item in impl_items {
- v.process_impl_item(impl_item, map.local_def_id_from_node_id(item.id));
+ v.process_impl_item(impl_item, map.local_def_id_from_node_id(item.id).to_def_id());
}
});
}
let name = item.ident.to_string();
let qualname = format!(
"::{}",
- self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id))
+ self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id).to_def_id())
);
let mut val = name.clone();
if !generics.params.is_empty() {
self.process_generic_params(generics, &qualname, item.id);
for method in methods {
let map = &self.tcx.hir();
- self.process_trait_item(method, map.local_def_id_from_node_id(item.id))
+ self.process_trait_item(method, map.local_def_id_from_node_id(item.id).to_def_id())
}
}
let name = trait_item.ident.name.to_string();
let qualname = format!(
"::{}",
- self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(trait_item.id))
+ self.tcx.def_path_str(
+ self.tcx.hir().local_def_id_from_node_id(trait_item.id).to_def_id()
+ )
);
if !self.span.filter_generated(trait_item.ident.span) {
// Make a comma-separated list of names of imported modules.
let def_id = self.tcx.hir().local_def_id_from_node_id(id);
- let names = self.tcx.names_imported_by_glob_use(def_id);
+ let names = self.tcx.names_imported_by_glob_use(def_id.to_def_id());
let names: Vec<_> = names.iter().map(|n| n.to_string()).collect();
// Otherwise it's a span with wrong macro expansion info, which
// only get called for the root module of a crate.
assert_eq!(id, ast::CRATE_NODE_ID);
- let qualname =
- format!("::{}", self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(id)));
+ let qualname = format!(
+ "::{}",
+ self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(id).to_def_id())
+ );
let sm = self.tcx.sess.source_map();
let filename = sm.span_to_filename(span);
TyAlias(_, ref ty_params, _, ref ty) => {
let qualname = format!(
"::{}",
- self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id))
+ self.tcx.def_path_str(
+ self.tcx.hir().local_def_id_from_node_id(item.id).to_def_id()
+ )
);
let value = match ty {
Some(ty) => ty_to_string(&ty),
pub fn get_extern_item_data(&self, item: &ast::ForeignItem) -> Option<Data> {
let qualname = format!(
"::{}",
- self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id))
+ self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id).to_def_id())
);
match item.kind {
ast::ForeignItemKind::Fn(_, ref sig, ref generics, _) => {
ast::ItemKind::Fn(_, ref sig, .., ref generics, _) => {
let qualname = format!(
"::{}",
- self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id))
+ self.tcx.def_path_str(
+ self.tcx.hir().local_def_id_from_node_id(item.id).to_def_id()
+ )
);
filter!(self.span_utils, item.ident.span);
Some(Data::DefData(Def {
ast::ItemKind::Static(ref typ, ..) => {
let qualname = format!(
"::{}",
- self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id))
+ self.tcx.def_path_str(
+ self.tcx.hir().local_def_id_from_node_id(item.id).to_def_id()
+ )
);
filter!(self.span_utils, item.ident.span);
ast::ItemKind::Const(_, ref typ, _) => {
let qualname = format!(
"::{}",
- self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id))
+ self.tcx.def_path_str(
+ self.tcx.hir().local_def_id_from_node_id(item.id).to_def_id()
+ )
);
filter!(self.span_utils, item.ident.span);
ast::ItemKind::Mod(ref m) => {
let qualname = format!(
"::{}",
- self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id))
+ self.tcx.def_path_str(
+ self.tcx.hir().local_def_id_from_node_id(item.id).to_def_id()
+ )
);
let sm = self.tcx.sess.source_map();
let name = item.ident.to_string();
let qualname = format!(
"::{}",
- self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id))
+ self.tcx.def_path_str(
+ self.tcx.hir().local_def_id_from_node_id(item.id).to_def_id()
+ )
);
filter!(self.span_utils, item.ident.span);
let variants_str =
let name = ident.to_string();
let qualname = format!(
"::{}::{}",
- self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(scope)),
+ self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(scope).to_def_id()),
ident
);
filter!(self.span_utils, ident.span);
- let def_id = self.tcx.hir().local_def_id_from_node_id(field.id);
+ let def_id = self.tcx.hir().local_def_id_from_node_id(field.id).to_def_id();
let typ = self.tcx.type_of(def_id).to_string();
let id = id_from_node_id(field.id, self);
// which the method is declared in, followed by the method's name.
let (qualname, parent_scope, decl_id, docs, attributes) = match self
.tcx
- .impl_of_method(self.tcx.hir().local_def_id_from_node_id(id))
+ .impl_of_method(self.tcx.hir().local_def_id_from_node_id(id).to_def_id())
{
Some(impl_id) => match self.tcx.hir().get_if_local(impl_id) {
Some(Node::Item(item)) => match item.kind {
);
}
},
- None => match self.tcx.trait_of_item(self.tcx.hir().local_def_id_from_node_id(id)) {
+ None => match self
+ .tcx
+ .trait_of_item(self.tcx.hir().local_def_id_from_node_id(id).to_def_id())
+ {
Some(def_id) => {
let mut docs = String::new();
let mut attrs = vec![];
name: None,
attrs: clean::Attributes::default(),
source: clean::Span::empty(),
- def_id: cx.tcx.hir().local_def_id_from_node_id(ast::CRATE_NODE_ID),
+ def_id: cx
+ .tcx
+ .hir()
+ .local_def_id_from_node_id(ast::CRATE_NODE_ID)
+ .to_def_id(),
visibility: clean::Public,
stability: None,
deprecation: None,
BareFunction(box BareFunctionDecl {
unsafety: sig.unsafety(),
generic_params: Vec::new(),
- decl: (local_def_id, sig).clean(cx),
+ decl: (local_def_id.to_def_id(), sig).clean(cx),
abi: sig.abi(),
})
}
name: None,
attrs: self.attrs.clean(cx),
source: self.whence.clean(cx),
- def_id: cx.tcx.hir().local_def_id_from_node_id(ast::CRATE_NODE_ID),
+ def_id: cx.tcx.hir().local_def_id_from_node_id(ast::CRATE_NODE_ID).to_def_id(),
visibility: self.vis.clean(cx),
stability: None,
deprecation: None,