about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPietro Albini <pietro@pietroalbini.org>2019-06-04 22:39:35 +0200
committerGitHub <noreply@github.com>2019-06-04 22:39:35 +0200
commit93271d159e10b8216678ddf6b9ca5bf68c569de1 (patch)
tree4fef9805e65ce2ad2639c8faef913847f561ec88
parent97c9437585edafb59dc24701578dc0f20756178c (diff)
parentcb6beef46079183850d0a56895e630c6b5fb4ce5 (diff)
Rollup merge of #61069 - Zoxc:drop-borrow-fix, r=pnkfelix
Make MIR drop terminators borrow the dropped location

r? @eddyb
cc @tmandry
-rw-r--r--src/librustc_mir/dataflow/impls/borrowed_locals.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/librustc_mir/dataflow/impls/borrowed_locals.rs b/src/librustc_mir/dataflow/impls/borrowed_locals.rs
index 47af10a1c50..55ec46566a4 100644
--- a/src/librustc_mir/dataflow/impls/borrowed_locals.rs
+++ b/src/librustc_mir/dataflow/impls/borrowed_locals.rs
@@ -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(