Skip to content

Commit 5fa4351

Browse files
committed
Revert HirIdify_rustc
This reverts commit c3d2490, reversing changes made to 68650ca.
1 parent ce4af95 commit 5fa4351

File tree

9 files changed

+33
-30
lines changed

9 files changed

+33
-30
lines changed

src/librustc/infer/error_reporting/mod.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ use crate::hir::def_id::DefId;
5656
use crate::hir::Node;
5757
use crate::middle::region;
5858
use std::{cmp, fmt};
59+
use syntax::ast::DUMMY_NODE_ID;
5960
use syntax_pos::{Pos, Span};
6061
use crate::traits::{ObligationCause, ObligationCauseCode};
6162
use crate::ty::error::TypeError;
@@ -181,8 +182,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
181182
let cm = self.sess.source_map();
182183

183184
let scope = region.free_region_binding_scope(self);
184-
let node = self.hir().as_local_hir_id(scope).unwrap_or(hir::DUMMY_HIR_ID);
185-
let tag = match self.hir().find_by_hir_id(node) {
185+
let node = self.hir().as_local_node_id(scope).unwrap_or(DUMMY_NODE_ID);
186+
let tag = match self.hir().find(node) {
186187
Some(Node::Block(_)) | Some(Node::Expr(_)) => "body",
187188
Some(Node::Item(it)) => Self::item_scope_tag(&it),
188189
Some(Node::TraitItem(it)) => Self::trait_item_scope_tag(&it),
@@ -191,7 +192,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
191192
};
192193
let (prefix, span) = match *region {
193194
ty::ReEarlyBound(ref br) => {
194-
let mut sp = cm.def_span(self.hir().span_by_hir_id(node));
195+
let mut sp = cm.def_span(self.hir().span(node));
195196
if let Some(param) = self.hir()
196197
.get_generics(scope)
197198
.and_then(|generics| generics.get_named(&br.name))
@@ -204,7 +205,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
204205
bound_region: ty::BoundRegion::BrNamed(_, ref name),
205206
..
206207
}) => {
207-
let mut sp = cm.def_span(self.hir().span_by_hir_id(node));
208+
let mut sp = cm.def_span(self.hir().span(node));
208209
if let Some(param) = self.hir()
209210
.get_generics(scope)
210211
.and_then(|generics| generics.get_named(&name))
@@ -216,15 +217,15 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
216217
ty::ReFree(ref fr) => match fr.bound_region {
217218
ty::BrAnon(idx) => (
218219
format!("the anonymous lifetime #{} defined on", idx + 1),
219-
self.hir().span_by_hir_id(node),
220+
self.hir().span(node),
220221
),
221222
ty::BrFresh(_) => (
222223
"an anonymous lifetime defined on".to_owned(),
223-
self.hir().span_by_hir_id(node),
224+
self.hir().span(node),
224225
),
225226
_ => (
226227
format!("the lifetime {} as defined on", fr.bound_region),
227-
cm.def_span(self.hir().span_by_hir_id(node)),
228+
cm.def_span(self.hir().span(node)),
228229
),
229230
},
230231
_ => bug!(),
@@ -1450,7 +1451,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
14501451
format!(" for lifetime parameter `{}` in coherence check", name)
14511452
}
14521453
infer::UpvarRegion(ref upvar_id, _) => {
1453-
let var_name = self.tcx.hir().name_by_hir_id(upvar_id.var_path.hir_id);
1454+
let var_node_id = self.tcx.hir().hir_to_node_id(upvar_id.var_path.hir_id);
1455+
let var_name = self.tcx.hir().name(var_node_id);
14541456
format!(" for capture of `{}` by closure", var_name)
14551457
}
14561458
infer::NLL(..) => bug!("NLL variable found in lexical phase"),

src/librustc/infer/error_reporting/note.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
3131
"...so that reference does not outlive borrowed content");
3232
}
3333
infer::ReborrowUpvar(span, ref upvar_id) => {
34-
let var_name = self.tcx.hir().name_by_hir_id(upvar_id.var_path.hir_id);
34+
let var_node_id = self.tcx.hir().hir_to_node_id(upvar_id.var_path.hir_id);
35+
let var_name = self.tcx.hir().name(var_node_id);
3536
err.span_note(span,
3637
&format!("...so that closure can access `{}`", var_name));
3738
}
@@ -163,7 +164,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
163164
err
164165
}
165166
infer::ReborrowUpvar(span, ref upvar_id) => {
166-
let var_name = self.tcx.hir().name_by_hir_id(upvar_id.var_path.hir_id);
167+
let var_node_id = self.tcx.hir().hir_to_node_id(upvar_id.var_path.hir_id);
168+
let var_name = self.tcx.hir().name(var_node_id);
167169
let mut err = struct_span_err!(self.tcx.sess,
168170
span,
169171
E0313,

src/librustc/middle/reachable.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
177177
// Check the impl. If the generics on the self
178178
// type of the impl require inlining, this method
179179
// does too.
180-
let impl_hir_id = self.tcx.hir().as_local_hir_id(impl_did).unwrap();
181-
match self.tcx.hir().expect_item_by_hir_id(impl_hir_id).node {
180+
let impl_node_id = self.tcx.hir().as_local_node_id(impl_did).unwrap();
181+
match self.tcx.hir().expect_item(impl_node_id).node {
182182
hir::ItemKind::Impl(..) => {
183183
let generics = self.tcx.generics_of(impl_did);
184184
generics.requires_monomorphization(self.tcx)

src/librustc/middle/resolve_lifetime.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1248,12 +1248,12 @@ fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body) {
12481248
} => {
12491249
// FIXME (#24278): non-hygienic comparison
12501250
if let Some(def) = lifetimes.get(&hir::ParamName::Plain(label.modern())) {
1251-
let hir_id = tcx.hir().as_local_hir_id(def.id().unwrap()).unwrap();
1251+
let node_id = tcx.hir().as_local_node_id(def.id().unwrap()).unwrap();
12521252

12531253
signal_shadowing_problem(
12541254
tcx,
12551255
label.name,
1256-
original_lifetime(tcx.hir().span_by_hir_id(hir_id)),
1256+
original_lifetime(tcx.hir().span(node_id)),
12571257
shadower_label(label.span),
12581258
);
12591259
return;
@@ -2593,12 +2593,12 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
25932593
ref lifetimes, s, ..
25942594
} => {
25952595
if let Some(&def) = lifetimes.get(&param.name.modern()) {
2596-
let hir_id = self.tcx.hir().as_local_hir_id(def.id().unwrap()).unwrap();
2596+
let node_id = self.tcx.hir().as_local_node_id(def.id().unwrap()).unwrap();
25972597

25982598
signal_shadowing_problem(
25992599
self.tcx,
26002600
param.name.ident().name,
2601-
original_lifetime(self.tcx.hir().span_by_hir_id(hir_id)),
2601+
original_lifetime(self.tcx.hir().span(node_id)),
26022602
shadower_lifetime(&param),
26032603
);
26042604
return;

src/librustc/traits/error_reporting.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1035,8 +1035,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
10351035
).collect::<Vec<_>>())
10361036
}
10371037
Node::StructCtor(ref variant_data) => {
1038-
(self.tcx.sess.source_map().def_span(
1039-
self.tcx.hir().span_by_hir_id(variant_data.hir_id())),
1038+
(self.tcx.sess.source_map().def_span(self.tcx.hir().span(variant_data.id())),
10401039
vec![ArgKind::empty(); variant_data.fields().len()])
10411040
}
10421041
_ => panic!("non-FnLike node found: {:?}", node),

src/librustc/traits/util.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -525,9 +525,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
525525
}
526526

527527
pub fn impl_is_default(self, node_item_def_id: DefId) -> bool {
528-
match self.hir().as_local_hir_id(node_item_def_id) {
529-
Some(hir_id) => {
530-
let item = self.hir().expect_item_by_hir_id(hir_id);
528+
match self.hir().as_local_node_id(node_item_def_id) {
529+
Some(node_id) => {
530+
let item = self.hir().expect_item(node_id);
531531
if let hir::ItemKind::Impl(_, _, defaultness, ..) = item.node {
532532
defaultness.is_default()
533533
} else {

src/librustc/ty/item_path.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
462462
// only occur very early in the compiler pipeline.
463463
let parent_def_id = self.parent_def_id(impl_def_id).unwrap();
464464
self.push_item_path(buffer, parent_def_id, pushed_prelude_crate);
465-
let hir_id = self.hir().as_local_hir_id(impl_def_id).unwrap();
466-
let item = self.hir().expect_item_by_hir_id(hir_id);
465+
let node_id = self.hir().as_local_node_id(impl_def_id).unwrap();
466+
let item = self.hir().expect_item(node_id);
467467
let span_str = self.sess.source_map().span_to_string(item.span);
468468
buffer.push(&format!("<impl at {}>", span_str));
469469
}

src/librustc/ty/mod.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -2939,8 +2939,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
29392939

29402940
/// Get the attributes of a definition.
29412941
pub fn get_attrs(self, did: DefId) -> Attributes<'gcx> {
2942-
if let Some(id) = self.hir().as_local_hir_id(did) {
2943-
Attributes::Borrowed(self.hir().attrs_by_hir_id(id))
2942+
if let Some(id) = self.hir().as_local_node_id(did) {
2943+
Attributes::Borrowed(self.hir().attrs(id))
29442944
} else {
29452945
Attributes::Owned(self.item_attrs(did))
29462946
}
@@ -2991,8 +2991,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
29912991
/// with the name of the crate containing the impl.
29922992
pub fn span_of_impl(self, impl_did: DefId) -> Result<Span, Symbol> {
29932993
if impl_did.is_local() {
2994-
let hir_id = self.hir().as_local_hir_id(impl_did).unwrap();
2995-
Ok(self.hir().span_by_hir_id(hir_id))
2994+
let node_id = self.hir().as_local_node_id(impl_did).unwrap();
2995+
Ok(self.hir().span(node_id))
29962996
} else {
29972997
Err(self.crate_name(impl_did.krate))
29982998
}
@@ -3110,8 +3110,8 @@ fn adt_sized_constraint<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
31103110
fn associated_item_def_ids<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
31113111
def_id: DefId)
31123112
-> Lrc<Vec<DefId>> {
3113-
let id = tcx.hir().as_local_hir_id(def_id).unwrap();
3114-
let item = tcx.hir().expect_item_by_hir_id(id);
3113+
let id = tcx.hir().as_local_node_id(def_id).unwrap();
3114+
let item = tcx.hir().expect_item(id);
31153115
let vec: Vec<_> = match item.node {
31163116
hir::ItemKind::Trait(.., ref trait_item_refs) => {
31173117
trait_item_refs.iter()

src/librustc/util/ppaux.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ impl fmt::Debug for ty::UpvarId {
802802
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
803803
write!(f, "UpvarId({:?};`{}`;{:?})",
804804
self.var_path.hir_id,
805-
ty::tls::with(|tcx| tcx.hir().name_by_hir_id(self.var_path.hir_id)),
805+
ty::tls::with(|tcx| tcx.hir().name(tcx.hir().hir_to_node_id(self.var_path.hir_id))),
806806
self.closure_expr_id)
807807
}
808808
}

0 commit comments

Comments
 (0)