Skip to content

Commit 1c8551b

Browse files
committed
renamve hir_to_string to node_to_string
1 parent d996c4d commit 1c8551b

File tree

12 files changed

+32
-32
lines changed

12 files changed

+32
-32
lines changed

src/librustc/cfg/graphviz.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl<'a, 'tcx> LabelledCFG<'a, 'tcx> {
2626
owner: self.tcx.hir().def_index_to_hir_id(self.cfg.owner_def_id.index).owner,
2727
local_id
2828
};
29-
let s = self.tcx.hir().hir_to_string(hir_id);
29+
let s = self.tcx.hir().node_to_string(hir_id);
3030

3131
// Replacing newlines with \\l causes each line to be left-aligned,
3232
// improving presentation of (long) pretty-printed expressions.

src/librustc/hir/map/hir_id_validator.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl<'a, 'hir: 'a> HirIdValidator<'a, 'hir> {
125125
let hir_id = self.hir_map.node_to_hir_id(node_id);
126126
missing_items.push(format!("[local_id: {}, node:{}]",
127127
local_id,
128-
self.hir_map.hir_to_string(hir_id)));
128+
self.hir_map.node_to_string(hir_id)));
129129
}
130130
self.error(|| format!(
131131
"ItemLocalIds not assigned densely in {}. \
@@ -139,7 +139,7 @@ impl<'a, 'hir: 'a> HirIdValidator<'a, 'hir> {
139139
owner: owner_def_index,
140140
local_id,
141141
})
142-
.map(|h| format!("({:?} {})", h, self.hir_map.hir_to_string(h)))
142+
.map(|h| format!("({:?} {})", h, self.hir_map.node_to_string(h)))
143143
.collect::<Vec<_>>()));
144144
}
145145
}
@@ -157,14 +157,14 @@ impl<'a, 'hir: 'a> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> {
157157

158158
if hir_id == hir::DUMMY_HIR_ID {
159159
self.error(|| format!("HirIdValidator: HirId {:?} is invalid",
160-
self.hir_map.hir_to_string(hir_id)));
160+
self.hir_map.node_to_string(hir_id)));
161161
return;
162162
}
163163

164164
if owner != hir_id.owner {
165165
self.error(|| format!(
166166
"HirIdValidator: The recorded owner of {} is {} instead of {}",
167-
self.hir_map.hir_to_string(hir_id),
167+
self.hir_map.node_to_string(hir_id),
168168
self.hir_map.def_path(DefId::local(hir_id.owner)).to_string_no_crate(),
169169
self.hir_map.def_path(DefId::local(owner)).to_string_no_crate()));
170170
}

src/librustc/hir/map/mod.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ impl<'hir> Map<'hir> {
453453
pub fn body_owned_by(&self, id: HirId) -> BodyId {
454454
self.maybe_body_owned_by(id).unwrap_or_else(|| {
455455
span_bug!(self.span(id), "body_owned_by: {} has no associated body",
456-
self.hir_to_string(id));
456+
self.node_to_string(id));
457457
})
458458
}
459459

@@ -486,7 +486,7 @@ impl<'hir> Map<'hir> {
486486
Node::Item(&Item { node: ItemKind::Trait(..), .. }) |
487487
Node::Item(&Item { node: ItemKind::TraitAlias(..), .. }) => id,
488488
Node::GenericParam(_) => self.get_parent_node_by_hir_id(id),
489-
_ => bug!("ty_param_owner: {} not a type parameter", self.hir_to_string(id))
489+
_ => bug!("ty_param_owner: {} not a type parameter", self.node_to_string(id))
490490
}
491491
}
492492

@@ -495,7 +495,7 @@ impl<'hir> Map<'hir> {
495495
Node::Item(&Item { node: ItemKind::Trait(..), .. }) |
496496
Node::Item(&Item { node: ItemKind::TraitAlias(..), .. }) => kw::SelfUpper,
497497
Node::GenericParam(param) => param.name.ident().name,
498-
_ => bug!("ty_param_name: {} not a type parameter", self.hir_to_string(id)),
498+
_ => bug!("ty_param_name: {} not a type parameter", self.node_to_string(id)),
499499
}
500500
}
501501

@@ -874,27 +874,27 @@ impl<'hir> Map<'hir> {
874874
return nm.abi;
875875
}
876876
}
877-
bug!("expected foreign mod or inlined parent, found {}", self.hir_to_string(parent))
877+
bug!("expected foreign mod or inlined parent, found {}", self.node_to_string(parent))
878878
}
879879

880880
pub fn expect_item(&self, id: HirId) -> &'hir Item {
881881
match self.find_by_hir_id(id) { // read recorded by `find`
882882
Some(Node::Item(item)) => item,
883-
_ => bug!("expected item, found {}", self.hir_to_string(id))
883+
_ => bug!("expected item, found {}", self.node_to_string(id))
884884
}
885885
}
886886

887887
pub fn expect_impl_item(&self, id: HirId) -> &'hir ImplItem {
888888
match self.find_by_hir_id(id) {
889889
Some(Node::ImplItem(item)) => item,
890-
_ => bug!("expected impl item, found {}", self.hir_to_string(id))
890+
_ => bug!("expected impl item, found {}", self.node_to_string(id))
891891
}
892892
}
893893

894894
pub fn expect_trait_item(&self, id: HirId) -> &'hir TraitItem {
895895
match self.find_by_hir_id(id) {
896896
Some(Node::TraitItem(item)) => item,
897-
_ => bug!("expected trait item, found {}", self.hir_to_string(id))
897+
_ => bug!("expected trait item, found {}", self.node_to_string(id))
898898
}
899899
}
900900

@@ -904,26 +904,26 @@ impl<'hir> Map<'hir> {
904904
match i.node {
905905
ItemKind::Struct(ref struct_def, _) |
906906
ItemKind::Union(ref struct_def, _) => struct_def,
907-
_ => bug!("struct ID bound to non-struct {}", self.hir_to_string(id))
907+
_ => bug!("struct ID bound to non-struct {}", self.node_to_string(id))
908908
}
909909
}
910910
Some(Node::Variant(variant)) => &variant.node.data,
911911
Some(Node::Ctor(data)) => data,
912-
_ => bug!("expected struct or variant, found {}", self.hir_to_string(id))
912+
_ => bug!("expected struct or variant, found {}", self.node_to_string(id))
913913
}
914914
}
915915

916916
pub fn expect_variant(&self, id: HirId) -> &'hir Variant {
917917
match self.find_by_hir_id(id) {
918918
Some(Node::Variant(variant)) => variant,
919-
_ => bug!("expected variant, found {}", self.hir_to_string(id)),
919+
_ => bug!("expected variant, found {}", self.node_to_string(id)),
920920
}
921921
}
922922

923923
pub fn expect_foreign_item(&self, id: HirId) -> &'hir ForeignItem {
924924
match self.find_by_hir_id(id) {
925925
Some(Node::ForeignItem(item)) => item,
926-
_ => bug!("expected foreign item, found {}", self.hir_to_string(id))
926+
_ => bug!("expected foreign item, found {}", self.node_to_string(id))
927927
}
928928
}
929929

@@ -936,7 +936,7 @@ impl<'hir> Map<'hir> {
936936
pub fn expect_expr_by_hir_id(&self, id: HirId) -> &'hir Expr {
937937
match self.find_by_hir_id(id) { // read recorded by find
938938
Some(Node::Expr(expr)) => expr,
939-
_ => bug!("expected expr, found {}", self.hir_to_string(id))
939+
_ => bug!("expected expr, found {}", self.node_to_string(id))
940940
}
941941
}
942942

@@ -959,7 +959,7 @@ impl<'hir> Map<'hir> {
959959
Node::GenericParam(param) => param.name.ident().name,
960960
Node::Binding(&Pat { node: PatKind::Binding(_, _, l, _), .. }) => l.name,
961961
Node::Ctor(..) => self.name_by_hir_id(self.get_parent_item(id)),
962-
_ => bug!("no name for {}", self.hir_to_string(id))
962+
_ => bug!("no name for {}", self.node_to_string(id))
963963
}
964964
}
965965

@@ -1071,7 +1071,7 @@ impl<'hir> Map<'hir> {
10711071
self.as_local_hir_id(id).map(|id| self.span(id))
10721072
}
10731073

1074-
pub fn hir_to_string(&self, id: HirId) -> String {
1074+
pub fn node_to_string(&self, id: HirId) -> String {
10751075
hir_id_to_string(self, id, true)
10761076
}
10771077

src/librustc/infer/opaque_types/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
819819
},
820820
_ => bug!(
821821
"expected (impl) item, found {}",
822-
tcx.hir().hir_to_string(opaque_hir_id),
822+
tcx.hir().node_to_string(opaque_hir_id),
823823
),
824824
};
825825
if in_definition_scope {

src/librustc/middle/mem_categorization.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
501501
None if self.is_tainted_by_errors() => Err(()),
502502
None => {
503503
bug!("no type for node {}: {} in mem_categorization",
504-
id, self.tcx.hir().hir_to_string(id));
504+
id, self.tcx.hir().node_to_string(id));
505505
}
506506
}
507507
}

src/librustc/middle/reachable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
318318
_ => {
319319
bug!(
320320
"found unexpected node kind in worklist: {} ({:?})",
321-
self.tcx.hir().hir_to_string(search_item),
321+
self.tcx.hir().node_to_string(search_item),
322322
node,
323323
);
324324
}

src/librustc/middle/resolve_lifetime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2696,7 +2696,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
26962696

26972697
debug!(
26982698
"insert_lifetime: {} resolved to {:?} span={:?}",
2699-
self.tcx.hir().hir_to_string(lifetime_ref.hir_id),
2699+
self.tcx.hir().node_to_string(lifetime_ref.hir_id),
27002700
def,
27012701
self.tcx.sess.source_map().span_to_string(lifetime_ref.span)
27022702
);

src/librustc/ty/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ fn validate_hir_id_for_typeck_tables(local_id_root: Option<DefId>,
252252
ty::tls::with(|tcx| {
253253
bug!("node {} with HirId::owner {:?} cannot be placed in \
254254
TypeckTables with local_id_root {:?}",
255-
tcx.hir().hir_to_string(hir_id),
255+
tcx.hir().node_to_string(hir_id),
256256
DefId::local(hir_id.owner),
257257
local_id_root)
258258
});
@@ -554,7 +554,7 @@ impl<'tcx> TypeckTables<'tcx> {
554554
pub fn node_type(&self, id: hir::HirId) -> Ty<'tcx> {
555555
self.node_type_opt(id).unwrap_or_else(||
556556
bug!("node_type: no type for node `{}`",
557-
tls::with(|tcx| tcx.hir().hir_to_string(id)))
557+
tls::with(|tcx| tcx.hir().node_to_string(id)))
558558
)
559559
}
560560

src/librustc_borrowck/borrowck/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,12 +1508,12 @@ impl<'tcx> fmt::Debug for LoanPath<'tcx> {
15081508
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
15091509
match self.kind {
15101510
LpVar(id) => {
1511-
write!(f, "$({})", ty::tls::with(|tcx| tcx.hir().hir_to_string(id)))
1511+
write!(f, "$({})", ty::tls::with(|tcx| tcx.hir().node_to_string(id)))
15121512
}
15131513

15141514
LpUpvar(ty::UpvarId{ var_path: ty::UpvarPath {hir_id: var_id}, closure_expr_id }) => {
15151515
let s = ty::tls::with(|tcx| {
1516-
tcx.hir().hir_to_string(var_id)
1516+
tcx.hir().node_to_string(var_id)
15171517
});
15181518
write!(f, "$({} captured by id={:?})", s, closure_expr_id)
15191519
}
@@ -1547,7 +1547,7 @@ impl<'tcx> fmt::Display for LoanPath<'tcx> {
15471547

15481548
LpUpvar(ty::UpvarId{ var_path: ty::UpvarPath { hir_id }, closure_expr_id: _ }) => {
15491549
let s = ty::tls::with(|tcx| {
1550-
tcx.hir().hir_to_string(hir_id)
1550+
tcx.hir().node_to_string(hir_id)
15511551
});
15521552
write!(f, "$({} captured by closure)", s)
15531553
}

src/librustc_typeck/check/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2181,7 +2181,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
21812181
pub fn local_ty(&self, span: Span, nid: hir::HirId) -> LocalTy<'tcx> {
21822182
self.locals.borrow().get(&nid).cloned().unwrap_or_else(||
21832183
span_bug!(span, "no type for local variable {}",
2184-
self.tcx.hir().hir_to_string(nid))
2184+
self.tcx.hir().node_to_string(nid))
21852185
)
21862186
}
21872187

@@ -2518,7 +2518,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
25182518
None if self.is_tainted_by_errors() => self.tcx.types.err,
25192519
None => {
25202520
bug!("no type for node {}: {} in fcx {}",
2521-
id, self.tcx.hir().hir_to_string(id),
2521+
id, self.tcx.hir().node_to_string(id),
25222522
self.tag());
25232523
}
25242524
}

src/librustc_typeck/coherence/orphan.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl ItemLikeVisitor<'v> for OrphanChecker<'tcx> {
2626
// "Trait" impl
2727
if let hir::ItemKind::Impl(.., Some(_), _, _) = item.node {
2828
debug!("coherence2::orphan check: trait impl {}",
29-
self.tcx.hir().hir_to_string(item.hir_id));
29+
self.tcx.hir().node_to_string(item.hir_id));
3030
let trait_ref = self.tcx.impl_trait_ref(def_id).unwrap();
3131
let trait_def_id = trait_ref.def_id;
3232
let cm = self.tcx.sess.source_map();

src/librustc_typeck/variance/terms.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ impl<'a, 'tcx> TermsContext<'a, 'tcx> {
129129
impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for TermsContext<'a, 'tcx> {
130130
fn visit_item(&mut self, item: &hir::Item) {
131131
debug!("add_inferreds for item {}",
132-
self.tcx.hir().hir_to_string(item.hir_id));
132+
self.tcx.hir().node_to_string(item.hir_id));
133133

134134
match item.node {
135135
hir::ItemKind::Struct(ref struct_def, _) |

0 commit comments

Comments
 (0)