Skip to content

Commit 44752c2

Browse files
committed
mir: partially HirIdify
1 parent 8bf7fda commit 44752c2

File tree

8 files changed

+20
-23
lines changed

8 files changed

+20
-23
lines changed

src/librustc_mir/borrow_check/error_reporting.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -833,13 +833,13 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
833833
format!("`{}` would have to be valid for `{}`...", name, region_name),
834834
);
835835

836-
if let Some(fn_node_id) = self.infcx.tcx.hir().as_local_node_id(self.mir_def_id) {
836+
if let Some(fn_hir_id) = self.infcx.tcx.hir().as_local_hir_id(self.mir_def_id) {
837837
err.span_label(
838838
drop_span,
839839
format!(
840840
"...but `{}` will be dropped here, when the function `{}` returns",
841841
name,
842-
self.infcx.tcx.hir().name(fn_node_id),
842+
self.infcx.tcx.hir().name_by_hir_id(fn_hir_id),
843843
),
844844
);
845845

src/librustc_mir/borrow_check/move_errors.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,8 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> {
308308
let upvar_decl = &self.mir.upvar_decls[field.index()];
309309
let upvar_hir_id =
310310
upvar_decl.var_hir_id.assert_crate_local();
311-
let upvar_node_id =
312-
self.infcx.tcx.hir().hir_to_node_id(upvar_hir_id);
313-
let upvar_span = self.infcx.tcx.hir().span(upvar_node_id);
311+
let upvar_span = self.infcx.tcx.hir().span_by_hir_id(
312+
upvar_hir_id);
314313
diag.span_label(upvar_span, "captured outer variable");
315314
break;
316315
}

src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc::ty::subst::{Substs, UnpackedKind};
1010
use rustc::ty::{self, RegionKind, RegionVid, Ty, TyCtxt};
1111
use rustc::util::ppaux::RegionHighlightMode;
1212
use rustc_errors::DiagnosticBuilder;
13-
use syntax::ast::{Name, DUMMY_NODE_ID};
13+
use syntax::ast::Name;
1414
use syntax::symbol::keywords;
1515
use syntax_pos::Span;
1616
use syntax_pos::symbol::InternedString;
@@ -293,9 +293,9 @@ impl<'tcx> RegionInferenceContext<'tcx> {
293293
name: &InternedString,
294294
) -> Span {
295295
let scope = error_region.free_region_binding_scope(tcx);
296-
let node = tcx.hir().as_local_node_id(scope).unwrap_or(DUMMY_NODE_ID);
296+
let node = tcx.hir().as_local_hir_id(scope).unwrap_or(hir::DUMMY_HIR_ID);
297297

298-
let span = tcx.sess.source_map().def_span(tcx.hir().span(node));
298+
let span = tcx.sess.source_map().def_span(tcx.hir().span_by_hir_id(node));
299299
if let Some(param) = tcx.hir()
300300
.get_generics(scope)
301301
.and_then(|generics| generics.get_named(name))

src/librustc_mir/borrow_check/nll/region_infer/error_reporting/var_name.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,10 @@ impl<'tcx> RegionInferenceContext<'tcx> {
7171
upvar_index: usize,
7272
) -> (Symbol, Span) {
7373
let upvar_hir_id = mir.upvar_decls[upvar_index].var_hir_id.assert_crate_local();
74-
let upvar_node_id = tcx.hir().hir_to_node_id(upvar_hir_id);
75-
debug!("get_upvar_name_and_span_for_region: upvar_node_id={:?}", upvar_node_id);
74+
debug!("get_upvar_name_and_span_for_region: upvar_hir_id={:?}", upvar_hir_id);
7675

77-
let upvar_name = tcx.hir().name(upvar_node_id);
78-
let upvar_span = tcx.hir().span(upvar_node_id);
76+
let upvar_name = tcx.hir().name_by_hir_id(upvar_hir_id);
77+
let upvar_span = tcx.hir().span_by_hir_id(upvar_hir_id);
7978
debug!("get_upvar_name_and_span_for_region: upvar_name={:?} upvar_span={:?}",
8079
upvar_name, upvar_span);
8180

src/librustc_mir/borrow_check/nll/universal_regions.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -771,9 +771,8 @@ fn for_each_late_bound_region_defined_on<'tcx>(
771771
owner: fn_def_id.index,
772772
local_id: *late_bound,
773773
};
774-
let region_node_id = tcx.hir().hir_to_node_id(hir_id);
775-
let name = tcx.hir().name(region_node_id).as_interned_str();
776-
let region_def_id = tcx.hir().local_def_id(region_node_id);
774+
let name = tcx.hir().name_by_hir_id(hir_id).as_interned_str();
775+
let region_def_id = tcx.hir().local_def_id_from_hir_id(hir_id);
777776
let liberated_region = tcx.mk_region(ty::ReFree(ty::FreeRegion {
778777
scope: fn_def_id,
779778
bound_region: ty::BoundRegion::BrNamed(region_def_id, name),

src/librustc_mir/build/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'t
6464
) => {
6565
(*body_id, ty.span)
6666
}
67-
Node::AnonConst(hir::AnonConst { body, id, .. }) => {
68-
(*body, tcx.hir().span(*id))
67+
Node::AnonConst(hir::AnonConst { body, hir_id, .. }) => {
68+
(*body, tcx.hir().span_by_hir_id(*hir_id))
6969
}
7070

7171
_ => span_bug!(tcx.hir().span(id), "can't build MIR for {:?}", def_id),
@@ -114,7 +114,7 @@ pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'t
114114
let self_arg;
115115
if let Some(ref fn_decl) = tcx.hir().fn_decl(owner_id) {
116116
let ty_hir_id = fn_decl.inputs[index].hir_id;
117-
let ty_span = tcx.hir().span(tcx.hir().hir_to_node_id(ty_hir_id));
117+
let ty_span = tcx.hir().span_by_hir_id(ty_hir_id);
118118
opt_ty_info = Some(ty_span);
119119
self_arg = if index == 0 && fn_decl.implicit_self.has_implicit_self() {
120120
match fn_decl.implicit_self {

src/librustc_mir/hair/cx/block.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ fn mirror_stmts<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
4848
for (index, stmt) in stmts.iter().enumerate() {
4949
let hir_id = stmt.hir_id;
5050
let opt_dxn_ext = cx.region_scope_tree.opt_destruction_scope(hir_id.local_id);
51-
let stmt_span = StatementSpan(cx.tcx.hir().span(stmt.id));
51+
let stmt_span = StatementSpan(cx.tcx.hir().span_by_hir_id(hir_id));
5252
match stmt.node {
5353
hir::StmtKind::Expr(ref expr) |
5454
hir::StmtKind::Semi(ref expr) => {

src/librustc_mir/monomorphize/collector.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,8 @@ fn check_recursion_limit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
450450
if recursion_depth > *tcx.sess.recursion_limit.get() {
451451
let error = format!("reached the recursion limit while instantiating `{}`",
452452
instance);
453-
if let Some(node_id) = tcx.hir().as_local_node_id(def_id) {
454-
tcx.sess.span_fatal(tcx.hir().span(node_id), &error);
453+
if let Some(hir_id) = tcx.hir().as_local_hir_id(def_id) {
454+
tcx.sess.span_fatal(tcx.hir().span_by_hir_id(hir_id), &error);
455455
} else {
456456
tcx.sess.fatal(&error);
457457
}
@@ -482,8 +482,8 @@ fn check_type_length_limit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
482482
let instance_name = instance.to_string();
483483
let msg = format!("reached the type-length limit while instantiating `{:.64}...`",
484484
instance_name);
485-
let mut diag = if let Some(node_id) = tcx.hir().as_local_node_id(instance.def_id()) {
486-
tcx.sess.struct_span_fatal(tcx.hir().span(node_id), &msg)
485+
let mut diag = if let Some(hir_id) = tcx.hir().as_local_hir_id(instance.def_id()) {
486+
tcx.sess.struct_span_fatal(tcx.hir().span_by_hir_id(hir_id), &msg)
487487
} else {
488488
tcx.sess.struct_fatal(&msg)
489489
};

0 commit comments

Comments
 (0)