rustc: use call_site_extent for closure environment free regions.

This commit is contained in:
Eduard-Mihai Burtescu 2017-05-07 16:49:03 +03:00
parent bd8246be74
commit 9809fe0d02
2 changed files with 2 additions and 16 deletions

View File

@ -785,26 +785,12 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
cmt_result: cmt_<'tcx>)
-> cmt_<'tcx>
{
// Look up the node ID of the closure body so we can construct
// a free region within it
let fn_body_id = {
let fn_expr = match self.tcx().hir.find(upvar_id.closure_expr_id) {
Some(hir_map::NodeExpr(e)) => e,
_ => bug!()
};
match fn_expr.node {
hir::ExprClosure(.., body_id, _) => body_id,
_ => bug!()
}
};
// Region of environment pointer
let env_region = self.tcx().mk_region(ty::ReFree(ty::FreeRegion {
// The environment of a closure is guaranteed to
// outlive any bindings introduced in the body of the
// closure itself.
scope: Some(self.tcx().item_extent(fn_body_id.node_id)),
scope: Some(self.tcx().call_site_extent(upvar_id.closure_expr_id)),
bound_region: ty::BrEnv
}));

View File

@ -207,7 +207,7 @@ fn closure_self_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
let closure_ty = tcx.body_tables(body_id).node_id_to_type(closure_expr_id);
let region = ty::ReFree(ty::FreeRegion {
scope: Some(tcx.item_extent(body_id.node_id)),
scope: Some(tcx.call_site_extent(closure_expr_id)),
bound_region: ty::BoundRegion::BrEnv,
});
let region = tcx.mk_region(region);