Skip to content

Commit 8918881

Browse files
committed
Give index temporaries a drop scope
1 parent dbeed58 commit 8918881

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/librustc_mir/build/expr/as_place.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
7373
let (usize_ty, bool_ty) = (this.hir.usize_ty(), this.hir.bool_ty());
7474

7575
let slice = unpack!(block = this.as_place(block, lhs));
76-
// region_scope=None so place indexes live forever. They are scalars so they
77-
// do not need storage annotations, and they are often copied between
78-
// places.
7976
// Making this a *fresh* temporary also means we do not have to worry about
8077
// the index changing later: Nothing will ever change this temporary.
8178
// The "retagging" transformation (for Stacked Borrows) relies on this.
82-
let idx = unpack!(block = this.as_temp(block, None, index, Mutability::Mut));
79+
let idx = unpack!(block = this.as_temp(
80+
block,
81+
expr.temp_lifetime,
82+
index,
83+
Mutability::Not,
84+
));
8385

8486
// bounds check:
8587
let (len, lt) = (

0 commit comments

Comments
 (0)