Auto merge of #58152 - ljedrz:HirIdify_mir, r=Zoxc

Partially HirIdify mir

Another step towards https://github.com/rust-lang/rust/pull/57578.
This commit is contained in:
bors 2019-02-11 03:35:22 +00:00
commit 4424a2c31a
8 changed files with 20 additions and 23 deletions

View file

@ -833,13 +833,13 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
format!("`{}` would have to be valid for `{}`...", name, region_name),
);
if let Some(fn_node_id) = self.infcx.tcx.hir().as_local_node_id(self.mir_def_id) {
if let Some(fn_hir_id) = self.infcx.tcx.hir().as_local_hir_id(self.mir_def_id) {
err.span_label(
drop_span,
format!(
"...but `{}` will be dropped here, when the function `{}` returns",
name,
self.infcx.tcx.hir().name(fn_node_id),
self.infcx.tcx.hir().name_by_hir_id(fn_hir_id),
),
);

View file

@ -308,9 +308,8 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> {
let upvar_decl = &self.mir.upvar_decls[field.index()];
let upvar_hir_id =
upvar_decl.var_hir_id.assert_crate_local();
let upvar_node_id =
self.infcx.tcx.hir().hir_to_node_id(upvar_hir_id);
let upvar_span = self.infcx.tcx.hir().span(upvar_node_id);
let upvar_span = self.infcx.tcx.hir().span_by_hir_id(
upvar_hir_id);
diag.span_label(upvar_span, "captured outer variable");
break;
}

View file

@ -10,7 +10,7 @@ use rustc::ty::subst::{Substs, UnpackedKind};
use rustc::ty::{self, RegionKind, RegionVid, Ty, TyCtxt};
use rustc::util::ppaux::RegionHighlightMode;
use rustc_errors::DiagnosticBuilder;
use syntax::ast::{Name, DUMMY_NODE_ID};
use syntax::ast::Name;
use syntax::symbol::keywords;
use syntax_pos::Span;
use syntax_pos::symbol::InternedString;
@ -293,9 +293,9 @@ impl<'tcx> RegionInferenceContext<'tcx> {
name: &InternedString,
) -> Span {
let scope = error_region.free_region_binding_scope(tcx);
let node = tcx.hir().as_local_node_id(scope).unwrap_or(DUMMY_NODE_ID);
let node = tcx.hir().as_local_hir_id(scope).unwrap_or(hir::DUMMY_HIR_ID);
let span = tcx.sess.source_map().def_span(tcx.hir().span(node));
let span = tcx.sess.source_map().def_span(tcx.hir().span_by_hir_id(node));
if let Some(param) = tcx.hir()
.get_generics(scope)
.and_then(|generics| generics.get_named(name))

View file

@ -71,11 +71,10 @@ impl<'tcx> RegionInferenceContext<'tcx> {
upvar_index: usize,
) -> (Symbol, Span) {
let upvar_hir_id = mir.upvar_decls[upvar_index].var_hir_id.assert_crate_local();
let upvar_node_id = tcx.hir().hir_to_node_id(upvar_hir_id);
debug!("get_upvar_name_and_span_for_region: upvar_node_id={:?}", upvar_node_id);
debug!("get_upvar_name_and_span_for_region: upvar_hir_id={:?}", upvar_hir_id);
let upvar_name = tcx.hir().name(upvar_node_id);
let upvar_span = tcx.hir().span(upvar_node_id);
let upvar_name = tcx.hir().name_by_hir_id(upvar_hir_id);
let upvar_span = tcx.hir().span_by_hir_id(upvar_hir_id);
debug!("get_upvar_name_and_span_for_region: upvar_name={:?} upvar_span={:?}",
upvar_name, upvar_span);

View file

@ -771,9 +771,8 @@ fn for_each_late_bound_region_defined_on<'tcx>(
owner: fn_def_id.index,
local_id: *late_bound,
};
let region_node_id = tcx.hir().hir_to_node_id(hir_id);
let name = tcx.hir().name(region_node_id).as_interned_str();
let region_def_id = tcx.hir().local_def_id(region_node_id);
let name = tcx.hir().name_by_hir_id(hir_id).as_interned_str();
let region_def_id = tcx.hir().local_def_id_from_hir_id(hir_id);
let liberated_region = tcx.mk_region(ty::ReFree(ty::FreeRegion {
scope: fn_def_id,
bound_region: ty::BoundRegion::BrNamed(region_def_id, name),

View file

@ -64,8 +64,8 @@ pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'t
) => {
(*body_id, ty.span)
}
Node::AnonConst(hir::AnonConst { body, id, .. }) => {
(*body, tcx.hir().span(*id))
Node::AnonConst(hir::AnonConst { body, hir_id, .. }) => {
(*body, tcx.hir().span_by_hir_id(*hir_id))
}
_ => 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
let self_arg;
if let Some(ref fn_decl) = tcx.hir().fn_decl(owner_id) {
let ty_hir_id = fn_decl.inputs[index].hir_id;
let ty_span = tcx.hir().span(tcx.hir().hir_to_node_id(ty_hir_id));
let ty_span = tcx.hir().span_by_hir_id(ty_hir_id);
opt_ty_info = Some(ty_span);
self_arg = if index == 0 && fn_decl.implicit_self.has_implicit_self() {
match fn_decl.implicit_self {

View file

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

View file

@ -450,8 +450,8 @@ fn check_recursion_limit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
if recursion_depth > *tcx.sess.recursion_limit.get() {
let error = format!("reached the recursion limit while instantiating `{}`",
instance);
if let Some(node_id) = tcx.hir().as_local_node_id(def_id) {
tcx.sess.span_fatal(tcx.hir().span(node_id), &error);
if let Some(hir_id) = tcx.hir().as_local_hir_id(def_id) {
tcx.sess.span_fatal(tcx.hir().span_by_hir_id(hir_id), &error);
} else {
tcx.sess.fatal(&error);
}
@ -482,8 +482,8 @@ fn check_type_length_limit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
let instance_name = instance.to_string();
let msg = format!("reached the type-length limit while instantiating `{:.64}...`",
instance_name);
let mut diag = if let Some(node_id) = tcx.hir().as_local_node_id(instance.def_id()) {
tcx.sess.struct_span_fatal(tcx.hir().span(node_id), &msg)
let mut diag = if let Some(hir_id) = tcx.hir().as_local_hir_id(instance.def_id()) {
tcx.sess.struct_span_fatal(tcx.hir().span_by_hir_id(hir_id), &msg)
} else {
tcx.sess.struct_fatal(&msg)
};