Skip to content

Commit 83a3e04

Browse files
Don't treat locals as mutably borrowed after they're dropped
1 parent e81297d commit 83a3e04

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

src/librustc_mir/dataflow/impls/indirect_mutation.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -135,18 +135,11 @@ impl<'tcx> Visitor<'tcx> for TransferFunction<'_, '_, 'tcx> {
135135
fn visit_terminator(&mut self, terminator: &mir::Terminator<'tcx>, location: Location) {
136136
self.super_terminator(terminator, location);
137137

138-
match &terminator.kind {
139-
// Drop terminators borrow the location
140-
mir::TerminatorKind::Drop { location: dropped_place, .. } |
141-
mir::TerminatorKind::DropAndReplace { location: dropped_place, .. } => {
142-
match dropped_place.base {
143-
mir::PlaceBase::Local(dropped_local) if !dropped_place.is_indirect()
144-
=> self.trans.gen(dropped_local),
145-
146-
_ => (),
147-
}
148-
}
149-
_ => (),
138+
if let mir::TerminatorKind::Drop { location: _, .. }
139+
| mir::TerminatorKind::DropAndReplace { location: _, .. } = &terminator.kind
140+
{
141+
// Although drop terminators mutably borrow the location being dropped, that borrow
142+
// cannot live beyond the drop terminator because the dropped location is invalidated.
150143
}
151144
}
152145
}

0 commit comments

Comments
 (0)