Skip to content

Commit cb6beef

Browse files
committed
Make MIR drop terminators borrow the dropped location
1 parent 50a0def commit cb6beef

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/librustc_mir/dataflow/impls/borrowed_locals.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,20 @@ impl<'a, 'tcx> BitDenotation<'tcx> for HaveBeenBorrowedLocals<'a, 'tcx> {
5656
fn terminator_effect(&self,
5757
sets: &mut BlockSets<'_, Local>,
5858
loc: Location) {
59+
let terminator = self.mir[loc.block].terminator();
5960
BorrowedLocalsVisitor {
6061
sets,
61-
}.visit_terminator(self.mir[loc.block].terminator(), loc);
62+
}.visit_terminator(terminator, loc);
63+
match &terminator.kind {
64+
// Drop terminators borrows the location
65+
TerminatorKind::Drop { location, .. } |
66+
TerminatorKind::DropAndReplace { location, .. } => {
67+
if let Some(local) = find_local(location) {
68+
sets.gen(local);
69+
}
70+
}
71+
_ => (),
72+
}
6273
}
6374

6475
fn propagate_call_return(

0 commit comments

Comments
 (0)