diff options
| author | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2019-09-17 16:25:31 -0700 |
|---|---|---|
| committer | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2019-09-28 07:06:51 -0700 |
| commit | 83a3e04ed0ba59a1cdff333d4017019817cbf911 (patch) | |
| tree | aa898fdd94df6d87686e41c94a06556bec14e464 | |
| parent | e81297d990632d29a3a82ecbfc78dbc4e6017994 (diff) | |
| download | rust-83a3e04ed0ba59a1cdff333d4017019817cbf911.tar.gz rust-83a3e04ed0ba59a1cdff333d4017019817cbf911.zip | |
Don't treat locals as mutably borrowed after they're dropped
| -rw-r--r-- | src/librustc_mir/dataflow/impls/indirect_mutation.rs | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/librustc_mir/dataflow/impls/indirect_mutation.rs b/src/librustc_mir/dataflow/impls/indirect_mutation.rs index f45fdb21463..934b843cc40 100644 --- a/src/librustc_mir/dataflow/impls/indirect_mutation.rs +++ b/src/librustc_mir/dataflow/impls/indirect_mutation.rs @@ -135,18 +135,11 @@ impl<'tcx> Visitor<'tcx> for TransferFunction<'_, '_, 'tcx> { fn visit_terminator(&mut self, terminator: &mir::Terminator<'tcx>, location: Location) { self.super_terminator(terminator, location); - match &terminator.kind { - // Drop terminators borrow the location - mir::TerminatorKind::Drop { location: dropped_place, .. } | - mir::TerminatorKind::DropAndReplace { location: dropped_place, .. } => { - match dropped_place.base { - mir::PlaceBase::Local(dropped_local) if !dropped_place.is_indirect() - => self.trans.gen(dropped_local), - - _ => (), - } - } - _ => (), + if let mir::TerminatorKind::Drop { location: _, .. } + | mir::TerminatorKind::DropAndReplace { location: _, .. } = &terminator.kind + { + // Although drop terminators mutably borrow the location being dropped, that borrow + // cannot live beyond the drop terminator because the dropped location is invalidated. } } } |
