From 1c8551b0ebb4efc72dd1d57035672e5b1c915ac2 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Sun, 16 Jun 2019 17:30:02 +0200 Subject: [PATCH] renamve hir_to_string to node_to_string --- src/librustc/cfg/graphviz.rs | 2 +- src/librustc/hir/map/hir_id_validator.rs | 8 +++---- src/librustc/hir/map/mod.rs | 28 +++++++++++------------ src/librustc/infer/opaque_types/mod.rs | 2 +- src/librustc/middle/mem_categorization.rs | 2 +- src/librustc/middle/reachable.rs | 2 +- src/librustc/middle/resolve_lifetime.rs | 2 +- src/librustc/ty/context.rs | 4 ++-- src/librustc_borrowck/borrowck/mod.rs | 6 ++--- src/librustc_typeck/check/mod.rs | 4 ++-- src/librustc_typeck/coherence/orphan.rs | 2 +- src/librustc_typeck/variance/terms.rs | 2 +- 12 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/librustc/cfg/graphviz.rs b/src/librustc/cfg/graphviz.rs index 0bfb6b98e63..66963e5856e 100644 --- a/src/librustc/cfg/graphviz.rs +++ b/src/librustc/cfg/graphviz.rs @@ -26,7 +26,7 @@ fn local_id_to_string(&self, local_id: hir::ItemLocalId) -> String { owner: self.tcx.hir().def_index_to_hir_id(self.cfg.owner_def_id.index).owner, local_id }; - let s = self.tcx.hir().hir_to_string(hir_id); + let s = self.tcx.hir().node_to_string(hir_id); // Replacing newlines with \\l causes each line to be left-aligned, // improving presentation of (long) pretty-printed expressions. diff --git a/src/librustc/hir/map/hir_id_validator.rs b/src/librustc/hir/map/hir_id_validator.rs index 08ec2aeed29..d6ac7ea2ed7 100644 --- a/src/librustc/hir/map/hir_id_validator.rs +++ b/src/librustc/hir/map/hir_id_validator.rs @@ -125,7 +125,7 @@ fn check)>(&mut self, let hir_id = self.hir_map.node_to_hir_id(node_id); missing_items.push(format!("[local_id: {}, node:{}]", local_id, - self.hir_map.hir_to_string(hir_id))); + self.hir_map.node_to_string(hir_id))); } self.error(|| format!( "ItemLocalIds not assigned densely in {}. \ @@ -139,7 +139,7 @@ fn check)>(&mut self, owner: owner_def_index, local_id, }) - .map(|h| format!("({:?} {})", h, self.hir_map.hir_to_string(h))) + .map(|h| format!("({:?} {})", h, self.hir_map.node_to_string(h))) .collect::>())); } } @@ -157,14 +157,14 @@ fn visit_id(&mut self, hir_id: HirId) { if hir_id == hir::DUMMY_HIR_ID { self.error(|| format!("HirIdValidator: HirId {:?} is invalid", - self.hir_map.hir_to_string(hir_id))); + self.hir_map.node_to_string(hir_id))); return; } if owner != hir_id.owner { self.error(|| format!( "HirIdValidator: The recorded owner of {} is {} instead of {}", - self.hir_map.hir_to_string(hir_id), + self.hir_map.node_to_string(hir_id), self.hir_map.def_path(DefId::local(hir_id.owner)).to_string_no_crate(), self.hir_map.def_path(DefId::local(owner)).to_string_no_crate())); } diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index 5a45f04b637..26c08154647 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -453,7 +453,7 @@ pub fn maybe_body_owned_by(&self, hir_id: HirId) -> Option { pub fn body_owned_by(&self, id: HirId) -> BodyId { self.maybe_body_owned_by(id).unwrap_or_else(|| { span_bug!(self.span(id), "body_owned_by: {} has no associated body", - self.hir_to_string(id)); + self.node_to_string(id)); }) } @@ -486,7 +486,7 @@ pub fn ty_param_owner(&self, id: HirId) -> HirId { Node::Item(&Item { node: ItemKind::Trait(..), .. }) | Node::Item(&Item { node: ItemKind::TraitAlias(..), .. }) => id, Node::GenericParam(_) => self.get_parent_node_by_hir_id(id), - _ => bug!("ty_param_owner: {} not a type parameter", self.hir_to_string(id)) + _ => bug!("ty_param_owner: {} not a type parameter", self.node_to_string(id)) } } @@ -495,7 +495,7 @@ pub fn ty_param_name(&self, id: HirId) -> Name { Node::Item(&Item { node: ItemKind::Trait(..), .. }) | Node::Item(&Item { node: ItemKind::TraitAlias(..), .. }) => kw::SelfUpper, Node::GenericParam(param) => param.name.ident().name, - _ => bug!("ty_param_name: {} not a type parameter", self.hir_to_string(id)), + _ => bug!("ty_param_name: {} not a type parameter", self.node_to_string(id)), } } @@ -874,27 +874,27 @@ pub fn get_foreign_abi(&self, hir_id: HirId) -> Abi { return nm.abi; } } - bug!("expected foreign mod or inlined parent, found {}", self.hir_to_string(parent)) + bug!("expected foreign mod or inlined parent, found {}", self.node_to_string(parent)) } pub fn expect_item(&self, id: HirId) -> &'hir Item { match self.find_by_hir_id(id) { // read recorded by `find` Some(Node::Item(item)) => item, - _ => bug!("expected item, found {}", self.hir_to_string(id)) + _ => bug!("expected item, found {}", self.node_to_string(id)) } } pub fn expect_impl_item(&self, id: HirId) -> &'hir ImplItem { match self.find_by_hir_id(id) { Some(Node::ImplItem(item)) => item, - _ => bug!("expected impl item, found {}", self.hir_to_string(id)) + _ => bug!("expected impl item, found {}", self.node_to_string(id)) } } pub fn expect_trait_item(&self, id: HirId) -> &'hir TraitItem { match self.find_by_hir_id(id) { Some(Node::TraitItem(item)) => item, - _ => bug!("expected trait item, found {}", self.hir_to_string(id)) + _ => bug!("expected trait item, found {}", self.node_to_string(id)) } } @@ -904,26 +904,26 @@ pub fn expect_variant_data(&self, id: HirId) -> &'hir VariantData { match i.node { ItemKind::Struct(ref struct_def, _) | ItemKind::Union(ref struct_def, _) => struct_def, - _ => bug!("struct ID bound to non-struct {}", self.hir_to_string(id)) + _ => bug!("struct ID bound to non-struct {}", self.node_to_string(id)) } } Some(Node::Variant(variant)) => &variant.node.data, Some(Node::Ctor(data)) => data, - _ => bug!("expected struct or variant, found {}", self.hir_to_string(id)) + _ => bug!("expected struct or variant, found {}", self.node_to_string(id)) } } pub fn expect_variant(&self, id: HirId) -> &'hir Variant { match self.find_by_hir_id(id) { Some(Node::Variant(variant)) => variant, - _ => bug!("expected variant, found {}", self.hir_to_string(id)), + _ => bug!("expected variant, found {}", self.node_to_string(id)), } } pub fn expect_foreign_item(&self, id: HirId) -> &'hir ForeignItem { match self.find_by_hir_id(id) { Some(Node::ForeignItem(item)) => item, - _ => bug!("expected foreign item, found {}", self.hir_to_string(id)) + _ => bug!("expected foreign item, found {}", self.node_to_string(id)) } } @@ -936,7 +936,7 @@ pub fn expect_expr(&self, id: NodeId) -> &'hir Expr { pub fn expect_expr_by_hir_id(&self, id: HirId) -> &'hir Expr { match self.find_by_hir_id(id) { // read recorded by find Some(Node::Expr(expr)) => expr, - _ => bug!("expected expr, found {}", self.hir_to_string(id)) + _ => bug!("expected expr, found {}", self.node_to_string(id)) } } @@ -959,7 +959,7 @@ pub fn name_by_hir_id(&self, id: HirId) -> Name { Node::GenericParam(param) => param.name.ident().name, Node::Binding(&Pat { node: PatKind::Binding(_, _, l, _), .. }) => l.name, Node::Ctor(..) => self.name_by_hir_id(self.get_parent_item(id)), - _ => bug!("no name for {}", self.hir_to_string(id)) + _ => bug!("no name for {}", self.node_to_string(id)) } } @@ -1071,7 +1071,7 @@ pub fn span_if_local(&self, id: DefId) -> Option { self.as_local_hir_id(id).map(|id| self.span(id)) } - pub fn hir_to_string(&self, id: HirId) -> String { + pub fn node_to_string(&self, id: HirId) -> String { hir_id_to_string(self, id, true) } diff --git a/src/librustc/infer/opaque_types/mod.rs b/src/librustc/infer/opaque_types/mod.rs index 1c52b5775a0..328ace51a58 100644 --- a/src/librustc/infer/opaque_types/mod.rs +++ b/src/librustc/infer/opaque_types/mod.rs @@ -819,7 +819,7 @@ fn instantiate_opaque_types_in_map>(&mut self, value: &T) }, _ => bug!( "expected (impl) item, found {}", - tcx.hir().hir_to_string(opaque_hir_id), + tcx.hir().node_to_string(opaque_hir_id), ), }; if in_definition_scope { diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index a856430e68a..192e72383ac 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -501,7 +501,7 @@ fn resolve_type_vars_or_error(&self, None if self.is_tainted_by_errors() => Err(()), None => { bug!("no type for node {}: {} in mem_categorization", - id, self.tcx.hir().hir_to_string(id)); + id, self.tcx.hir().node_to_string(id)); } } } diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index 2285beb3758..628a44cbfe0 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -318,7 +318,7 @@ fn propagate_node(&mut self, node: &Node<'tcx>, _ => { bug!( "found unexpected node kind in worklist: {} ({:?})", - self.tcx.hir().hir_to_string(search_item), + self.tcx.hir().node_to_string(search_item), node, ); } diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 6f2c4b66f5e..76bff500634 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -2696,7 +2696,7 @@ fn insert_lifetime(&mut self, lifetime_ref: &'tcx hir::Lifetime, def: Region) { debug!( "insert_lifetime: {} resolved to {:?} span={:?}", - self.tcx.hir().hir_to_string(lifetime_ref.hir_id), + self.tcx.hir().node_to_string(lifetime_ref.hir_id), def, self.tcx.sess.source_map().span_to_string(lifetime_ref.span) ); diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index c32f62e88c4..b84ebd8afe8 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -252,7 +252,7 @@ fn validate_hir_id_for_typeck_tables(local_id_root: Option, ty::tls::with(|tcx| { bug!("node {} with HirId::owner {:?} cannot be placed in \ TypeckTables with local_id_root {:?}", - tcx.hir().hir_to_string(hir_id), + tcx.hir().node_to_string(hir_id), DefId::local(hir_id.owner), local_id_root) }); @@ -554,7 +554,7 @@ pub fn node_types_mut(&mut self) -> LocalTableInContextMut<'_, Ty<'tcx>> { pub fn node_type(&self, id: hir::HirId) -> Ty<'tcx> { self.node_type_opt(id).unwrap_or_else(|| bug!("node_type: no type for node `{}`", - tls::with(|tcx| tcx.hir().hir_to_string(id))) + tls::with(|tcx| tcx.hir().node_to_string(id))) ) } diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index cc9c83de179..23b28952935 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -1508,12 +1508,12 @@ impl<'tcx> fmt::Debug for LoanPath<'tcx> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.kind { LpVar(id) => { - write!(f, "$({})", ty::tls::with(|tcx| tcx.hir().hir_to_string(id))) + write!(f, "$({})", ty::tls::with(|tcx| tcx.hir().node_to_string(id))) } LpUpvar(ty::UpvarId{ var_path: ty::UpvarPath {hir_id: var_id}, closure_expr_id }) => { let s = ty::tls::with(|tcx| { - tcx.hir().hir_to_string(var_id) + tcx.hir().node_to_string(var_id) }); write!(f, "$({} captured by id={:?})", s, closure_expr_id) } @@ -1547,7 +1547,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { LpUpvar(ty::UpvarId{ var_path: ty::UpvarPath { hir_id }, closure_expr_id: _ }) => { let s = ty::tls::with(|tcx| { - tcx.hir().hir_to_string(hir_id) + tcx.hir().node_to_string(hir_id) }); write!(f, "$({} captured by closure)", s) } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index d4dbb68778e..10bfe9e034d 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -2181,7 +2181,7 @@ pub fn tag(&self) -> String { pub fn local_ty(&self, span: Span, nid: hir::HirId) -> LocalTy<'tcx> { self.locals.borrow().get(&nid).cloned().unwrap_or_else(|| span_bug!(span, "no type for local variable {}", - self.tcx.hir().hir_to_string(nid)) + self.tcx.hir().node_to_string(nid)) ) } @@ -2518,7 +2518,7 @@ pub fn node_ty(&self, id: hir::HirId) -> Ty<'tcx> { None if self.is_tainted_by_errors() => self.tcx.types.err, None => { bug!("no type for node {}: {} in fcx {}", - id, self.tcx.hir().hir_to_string(id), + id, self.tcx.hir().node_to_string(id), self.tag()); } } diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs index 43063d7b8d1..4e6fcfe0593 100644 --- a/src/librustc_typeck/coherence/orphan.rs +++ b/src/librustc_typeck/coherence/orphan.rs @@ -26,7 +26,7 @@ fn visit_item(&mut self, item: &hir::Item) { // "Trait" impl if let hir::ItemKind::Impl(.., Some(_), _, _) = item.node { debug!("coherence2::orphan check: trait impl {}", - self.tcx.hir().hir_to_string(item.hir_id)); + self.tcx.hir().node_to_string(item.hir_id)); let trait_ref = self.tcx.impl_trait_ref(def_id).unwrap(); let trait_def_id = trait_ref.def_id; let cm = self.tcx.sess.source_map(); diff --git a/src/librustc_typeck/variance/terms.rs b/src/librustc_typeck/variance/terms.rs index b120f995ad3..99f87ccb6f6 100644 --- a/src/librustc_typeck/variance/terms.rs +++ b/src/librustc_typeck/variance/terms.rs @@ -129,7 +129,7 @@ fn add_inferreds_for_item(&mut self, id: hir::HirId) { impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for TermsContext<'a, 'tcx> { fn visit_item(&mut self, item: &hir::Item) { debug!("add_inferreds for item {}", - self.tcx.hir().hir_to_string(item.hir_id)); + self.tcx.hir().node_to_string(item.hir_id)); match item.node { hir::ItemKind::Struct(ref struct_def, _) | -- 2.44.0