Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partially HirIdify mir #58152

Merged
merged 1 commit into from
Feb 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/librustc_mir/borrow_check/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
),
);

Expand Down
5 changes: 2 additions & 3 deletions src/librustc_mir/borrow_check/move_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
5 changes: 2 additions & 3 deletions src/librustc_mir/borrow_check/nll/universal_regions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_mir/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/hair/cx/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_mir/monomorphize/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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)
};
Expand Down