Skip to content

Commit

Permalink
Rollup merge of rust-lang#61069 - Zoxc:drop-borrow-fix, r=pnkfelix
Browse files Browse the repository at this point in the history
Make MIR drop terminators borrow the dropped location

r? @eddyb
cc @tmandry
  • Loading branch information
Centril committed Jun 4, 2019
2 parents 021a503 + cb6beef commit a3d9db4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/librustc_mir/dataflow/impls/borrowed_locals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,20 @@ impl<'a, 'tcx> BitDenotation<'tcx> for HaveBeenBorrowedLocals<'a, 'tcx> {
fn terminator_effect(&self,
sets: &mut BlockSets<'_, Local>,
loc: Location) {
let terminator = self.mir[loc.block].terminator();
BorrowedLocalsVisitor {
sets,
}.visit_terminator(self.mir[loc.block].terminator(), loc);
}.visit_terminator(terminator, loc);
match &terminator.kind {
// Drop terminators borrows the location
TerminatorKind::Drop { location, .. } |
TerminatorKind::DropAndReplace { location, .. } => {
if let Some(local) = find_local(location) {
sets.gen(local);
}
}
_ => (),
}
}

fn propagate_call_return(
Expand Down

0 comments on commit a3d9db4

Please sign in to comment.