Fix #43457 (and avoid some unneeded lookups to boot, woo).

This commit is contained in:
Felix S. Klock II 2017-08-25 16:08:03 +02:00
parent 6722996923
commit b8d8dc3c23

View file

@ -22,10 +22,7 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Block {
// We have to eagerly translate the "spine" of the statements
// in order to get the lexical scoping correctly.
let stmts = mirror_stmts(cx, self.id, &*self.stmts);
let opt_def_id = cx.tcx.hir.opt_local_def_id(self.id);
let opt_destruction_extent = opt_def_id.and_then(|def_id| {
cx.tcx.region_maps(def_id).opt_destruction_extent(self.id)
});
let opt_destruction_extent = cx.region_maps.opt_destruction_extent(self.id);
Block {
targeted_by_break: self.targeted_by_break,
extent: CodeExtent::Misc(self.id),
@ -42,11 +39,8 @@ fn mirror_stmts<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
stmts: &'tcx [hir::Stmt])
-> Vec<StmtRef<'tcx>> {
let mut result = vec![];
let opt_def_id = cx.tcx.hir.opt_local_def_id(block_id);
for (index, stmt) in stmts.iter().enumerate() {
let opt_dxn_ext = opt_def_id.and_then(|def_id| {
cx.tcx.region_maps(def_id).opt_destruction_extent(stmt.node.id())
});
let opt_dxn_ext = cx.region_maps.opt_destruction_extent(stmt.node.id());
match stmt.node {
hir::StmtExpr(ref expr, id) |
hir::StmtSemi(ref expr, id) => {