Skip to content

Commit

Permalink
Make MIR drop terminators borrow the dropped location
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoxc committed May 23, 2019
1 parent 50a0def commit cb6beef
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 cb6beef

Please sign in to comment.