From 89188815ed1ec2d6fa498e8dc1eeecdc26e355e4 Mon Sep 17 00:00:00 2001 From: Matthew Jasper Date: Sun, 7 Jul 2019 15:03:07 +0100 Subject: [PATCH] Give index temporaries a drop scope --- src/librustc_mir/build/expr/as_place.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/librustc_mir/build/expr/as_place.rs b/src/librustc_mir/build/expr/as_place.rs index 0640c01d255c..82accb47437c 100644 --- a/src/librustc_mir/build/expr/as_place.rs +++ b/src/librustc_mir/build/expr/as_place.rs @@ -73,13 +73,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let (usize_ty, bool_ty) = (this.hir.usize_ty(), this.hir.bool_ty()); let slice = unpack!(block = this.as_place(block, lhs)); - // region_scope=None so place indexes live forever. They are scalars so they - // do not need storage annotations, and they are often copied between - // places. // Making this a *fresh* temporary also means we do not have to worry about // the index changing later: Nothing will ever change this temporary. // The "retagging" transformation (for Stacked Borrows) relies on this. - let idx = unpack!(block = this.as_temp(block, None, index, Mutability::Mut)); + let idx = unpack!(block = this.as_temp( + block, + expr.temp_lifetime, + index, + Mutability::Not, + )); // bounds check: let (len, lt) = (