Skip to content

Commit 9809fe0

Browse files
committed
rustc: use call_site_extent for closure environment free regions.
1 parent bd8246b commit 9809fe0

File tree

2 files changed

+2
-16
lines changed

2 files changed

+2
-16
lines changed

src/librustc/middle/mem_categorization.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -785,26 +785,12 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
785785
cmt_result: cmt_<'tcx>)
786786
-> cmt_<'tcx>
787787
{
788-
// Look up the node ID of the closure body so we can construct
789-
// a free region within it
790-
let fn_body_id = {
791-
let fn_expr = match self.tcx().hir.find(upvar_id.closure_expr_id) {
792-
Some(hir_map::NodeExpr(e)) => e,
793-
_ => bug!()
794-
};
795-
796-
match fn_expr.node {
797-
hir::ExprClosure(.., body_id, _) => body_id,
798-
_ => bug!()
799-
}
800-
};
801-
802788
// Region of environment pointer
803789
let env_region = self.tcx().mk_region(ty::ReFree(ty::FreeRegion {
804790
// The environment of a closure is guaranteed to
805791
// outlive any bindings introduced in the body of the
806792
// closure itself.
807-
scope: Some(self.tcx().item_extent(fn_body_id.node_id)),
793+
scope: Some(self.tcx().call_site_extent(upvar_id.closure_expr_id)),
808794
bound_region: ty::BrEnv
809795
}));
810796

src/librustc_mir/build/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ fn closure_self_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
207207
let closure_ty = tcx.body_tables(body_id).node_id_to_type(closure_expr_id);
208208

209209
let region = ty::ReFree(ty::FreeRegion {
210-
scope: Some(tcx.item_extent(body_id.node_id)),
210+
scope: Some(tcx.call_site_extent(closure_expr_id)),
211211
bound_region: ty::BoundRegion::BrEnv,
212212
});
213213
let region = tcx.mk_region(region);

0 commit comments

Comments
 (0)