rustc: replace node_path_str with uses of def_path_str.
This commit is contained in:
parent
36f64f15fc
commit
27ddf2cec8
5 changed files with 32 additions and 23 deletions
|
@ -1351,7 +1351,8 @@ fn node_id_to_string(map: &Map<'_>, id: NodeId, include_id: bool) -> String {
|
|||
// the user-friendly path, otherwise fall back to stringifying DefPath.
|
||||
crate::ty::tls::with_opt(|tcx| {
|
||||
if let Some(tcx) = tcx {
|
||||
tcx.node_path_str(id)
|
||||
let def_id = map.local_def_id(id);
|
||||
tcx.def_path_str(def_id)
|
||||
} else if let Some(path) = map.def_path_from_id(id) {
|
||||
path.data.into_iter().map(|elem| {
|
||||
elem.data.to_string()
|
||||
|
|
|
@ -4,7 +4,6 @@ use crate::hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
|
|||
use crate::ty::{self, DefIdTree, Ty, TyCtxt, TypeFoldable};
|
||||
use crate::ty::subst::{Kind, Subst, SubstsRef, UnpackedKind};
|
||||
use crate::middle::cstore::{ExternCrate, ExternCrateSource};
|
||||
use syntax::ast;
|
||||
use syntax::symbol::{keywords, Symbol};
|
||||
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
|
@ -217,12 +216,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
.print_def_path(def_id, None, ns, iter::empty());
|
||||
s
|
||||
}
|
||||
|
||||
/// Returns a string identifying this local node-id.
|
||||
// FIXME(eddyb) remove in favor of calling `def_path_str` directly.
|
||||
pub fn node_path_str(self, id: ast::NodeId) -> String {
|
||||
self.def_path_str(self.hir().local_def_id(id))
|
||||
}
|
||||
}
|
||||
|
||||
impl<P: Printer> PrintCx<'a, 'gcx, 'tcx, P> {
|
||||
|
|
|
@ -471,7 +471,7 @@ impl<'b, 'tcx> HirPrinterSupport<'tcx> for TypedAnnotation<'b, 'tcx> {
|
|||
}
|
||||
|
||||
fn node_path(&self, id: ast::NodeId) -> Option<String> {
|
||||
Some(self.tcx.node_path_str(id))
|
||||
Some(self.tcx.def_path_str(self.tcx.hir().local_def_id(id)))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -429,7 +429,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
|
|||
vis: ast::Visibility,
|
||||
attrs: &'l [Attribute],
|
||||
) {
|
||||
let qualname = format!("::{}", self.tcx.node_path_str(id));
|
||||
let qualname = format!("::{}",
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id(id)));
|
||||
|
||||
if !self.span.filter_generated(ident.span) {
|
||||
let sig = sig::assoc_const_signature(id, ident.name, typ, expr, &self.save_ctxt);
|
||||
|
@ -470,7 +471,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
|
|||
) {
|
||||
debug!("process_struct {:?} {:?}", item, item.span);
|
||||
let name = item.ident.to_string();
|
||||
let qualname = format!("::{}", self.tcx.node_path_str(item.id));
|
||||
let qualname = format!("::{}",
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
|
||||
|
||||
let kind = match item.node {
|
||||
ast::ItemKind::Struct(_, _) => DefKind::Struct,
|
||||
|
@ -682,7 +684,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
|
|||
methods: &'l [ast::TraitItem],
|
||||
) {
|
||||
let name = item.ident.to_string();
|
||||
let qualname = format!("::{}", self.tcx.node_path_str(item.id));
|
||||
let qualname = format!("::{}",
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
|
||||
let mut val = name.clone();
|
||||
if !generics.params.is_empty() {
|
||||
val.push_str(&generic_params_to_string(&generics.params));
|
||||
|
@ -1093,7 +1096,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
|
|||
ast::TraitItemKind::Type(ref bounds, ref default_ty) => {
|
||||
// FIXME do something with _bounds (for type refs)
|
||||
let name = trait_item.ident.name.to_string();
|
||||
let qualname = format!("::{}", self.tcx.node_path_str(trait_item.id));
|
||||
let qualname = format!("::{}",
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id(trait_item.id)));
|
||||
|
||||
if !self.span.filter_generated(trait_item.ident.span) {
|
||||
let span = self.span_from_span(trait_item.ident.span);
|
||||
|
@ -1300,7 +1304,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc
|
|||
// only get called for the root module of a crate.
|
||||
assert_eq!(id, ast::CRATE_NODE_ID);
|
||||
|
||||
let qualname = format!("::{}", self.tcx.node_path_str(id));
|
||||
let qualname = format!("::{}",
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id(id)));
|
||||
|
||||
let cm = self.tcx.sess.source_map();
|
||||
let filename = cm.span_to_filename(span);
|
||||
|
@ -1389,7 +1394,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc
|
|||
self.nest_scope(item.id, |v| visit::walk_mod(v, m));
|
||||
}
|
||||
Ty(ref ty, ref ty_params) => {
|
||||
let qualname = format!("::{}", self.tcx.node_path_str(item.id));
|
||||
let qualname = format!("::{}",
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
|
||||
let value = ty_to_string(&ty);
|
||||
if !self.span.filter_generated(item.ident.span) {
|
||||
let span = self.span_from_span(item.ident.span);
|
||||
|
@ -1418,7 +1424,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc
|
|||
self.process_generic_params(ty_params, &qualname, item.id);
|
||||
}
|
||||
Existential(ref _bounds, ref ty_params) => {
|
||||
let qualname = format!("::{}", self.tcx.node_path_str(item.id));
|
||||
let qualname = format!("::{}",
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
|
||||
// FIXME do something with _bounds
|
||||
let value = String::new();
|
||||
if !self.span.filter_generated(item.ident.span) {
|
||||
|
|
|
@ -134,7 +134,8 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
|||
}
|
||||
|
||||
pub fn get_extern_item_data(&self, item: &ast::ForeignItem) -> Option<Data> {
|
||||
let qualname = format!("::{}", self.tcx.node_path_str(item.id));
|
||||
let qualname = format!("::{}",
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
|
||||
match item.node {
|
||||
ast::ForeignItemKind::Fn(ref decl, ref generics) => {
|
||||
filter!(self.span_utils, item.ident.span);
|
||||
|
@ -184,7 +185,8 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
|||
pub fn get_item_data(&self, item: &ast::Item) -> Option<Data> {
|
||||
match item.node {
|
||||
ast::ItemKind::Fn(ref decl, .., ref generics, _) => {
|
||||
let qualname = format!("::{}", self.tcx.node_path_str(item.id));
|
||||
let qualname = format!("::{}",
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
|
||||
filter!(self.span_utils, item.ident.span);
|
||||
Some(Data::DefData(Def {
|
||||
kind: DefKind::Function,
|
||||
|
@ -202,7 +204,8 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
|||
}))
|
||||
}
|
||||
ast::ItemKind::Static(ref typ, ..) => {
|
||||
let qualname = format!("::{}", self.tcx.node_path_str(item.id));
|
||||
let qualname = format!("::{}",
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
|
||||
|
||||
filter!(self.span_utils, item.ident.span);
|
||||
|
||||
|
@ -225,7 +228,8 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
|||
}))
|
||||
}
|
||||
ast::ItemKind::Const(ref typ, _) => {
|
||||
let qualname = format!("::{}", self.tcx.node_path_str(item.id));
|
||||
let qualname = format!("::{}",
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
|
||||
filter!(self.span_utils, item.ident.span);
|
||||
|
||||
let id = id_from_node_id(item.id, self);
|
||||
|
@ -247,7 +251,8 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
|||
}))
|
||||
}
|
||||
ast::ItemKind::Mod(ref m) => {
|
||||
let qualname = format!("::{}", self.tcx.node_path_str(item.id));
|
||||
let qualname = format!("::{}",
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
|
||||
|
||||
let cm = self.tcx.sess.source_map();
|
||||
let filename = cm.span_to_filename(m.inner);
|
||||
|
@ -274,7 +279,8 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
|||
}
|
||||
ast::ItemKind::Enum(ref def, _) => {
|
||||
let name = item.ident.to_string();
|
||||
let qualname = format!("::{}", self.tcx.node_path_str(item.id));
|
||||
let qualname = format!("::{}",
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
|
||||
filter!(self.span_utils, item.ident.span);
|
||||
let variants_str = def.variants
|
||||
.iter()
|
||||
|
@ -358,7 +364,9 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
|||
pub fn get_field_data(&self, field: &ast::StructField, scope: NodeId) -> Option<Def> {
|
||||
if let Some(ident) = field.ident {
|
||||
let name = ident.to_string();
|
||||
let qualname = format!("::{}::{}", self.tcx.node_path_str(scope), ident);
|
||||
let qualname = format!("::{}::{}",
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id(scope)),
|
||||
ident);
|
||||
filter!(self.span_utils, ident.span);
|
||||
let def_id = self.tcx.hir().local_def_id(field.id);
|
||||
let typ = self.tcx.type_of(def_id).to_string();
|
||||
|
|
Loading…
Add table
Reference in a new issue