@@ -685,17 +685,19 @@ impl<'cx, 'tcx> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtx
685685 TerminatorKind :: SwitchInt { discr, targets : _ } => {
686686 self . consume_operand ( loc, ( discr, span) , flow_state) ;
687687 }
688- TerminatorKind :: Drop { place, target : _, unwind : _ } => {
688+ TerminatorKind :: Drop { place, target : _, unwind : _, replace } => {
689689 debug ! (
690690 "visit_terminator_drop \
691691 loc: {:?} term: {:?} place: {:?} span: {:?}",
692692 loc, term, place, span
693693 ) ;
694694
695+ let write_kind =
696+ if * replace { WriteKind :: Replace } else { WriteKind :: StorageDeadOrDrop } ;
695697 self . access_place (
696698 loc,
697699 ( * place, span) ,
698- ( AccessDepth :: Drop , Write ( WriteKind :: StorageDeadOrDrop ) ) ,
700+ ( AccessDepth :: Drop , Write ( write_kind ) ) ,
699701 LocalMutationIsAllowed :: Yes ,
700702 flow_state,
701703 ) ;
@@ -885,6 +887,7 @@ enum ReadKind {
885887#[ derive( Copy , Clone , PartialEq , Eq , Debug ) ]
886888enum WriteKind {
887889 StorageDeadOrDrop ,
890+ Replace ,
888891 MutableBorrow ( BorrowKind ) ,
889892 Mutate ,
890893 Move ,
@@ -1132,13 +1135,21 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
11321135 this. buffer_error ( err) ;
11331136 }
11341137 WriteKind :: StorageDeadOrDrop => this
1135- . report_storage_dead_or_drop_of_borrowed ( location, place_span, borrow) ,
1138+ . report_borrowed_value_does_not_live_long_enough (
1139+ location,
1140+ borrow,
1141+ place_span,
1142+ Some ( WriteKind :: StorageDeadOrDrop ) ,
1143+ ) ,
11361144 WriteKind :: Mutate => {
11371145 this. report_illegal_mutation_of_borrowed ( location, place_span, borrow)
11381146 }
11391147 WriteKind :: Move => {
11401148 this. report_move_out_while_borrowed ( location, place_span, borrow)
11411149 }
1150+ WriteKind :: Replace => {
1151+ this. report_illegal_mutation_of_borrowed ( location, place_span, borrow)
1152+ }
11421153 }
11431154 Control :: Break
11441155 }
@@ -1982,12 +1993,14 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
19821993
19831994 Reservation (
19841995 WriteKind :: Move
1996+ | WriteKind :: Replace
19851997 | WriteKind :: StorageDeadOrDrop
19861998 | WriteKind :: MutableBorrow ( BorrowKind :: Shared )
19871999 | WriteKind :: MutableBorrow ( BorrowKind :: Shallow ) ,
19882000 )
19892001 | Write (
19902002 WriteKind :: Move
2003+ | WriteKind :: Replace
19912004 | WriteKind :: StorageDeadOrDrop
19922005 | WriteKind :: MutableBorrow ( BorrowKind :: Shared )
19932006 | WriteKind :: MutableBorrow ( BorrowKind :: Shallow ) ,
0 commit comments