@@ -685,17 +685,19 @@ impl<'cx, 'tcx> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtx
685
685
TerminatorKind :: SwitchInt { discr, targets : _ } => {
686
686
self . consume_operand ( loc, ( discr, span) , flow_state) ;
687
687
}
688
- TerminatorKind :: Drop { place, target : _, unwind : _ } => {
688
+ TerminatorKind :: Drop { place, target : _, unwind : _, replace } => {
689
689
debug ! (
690
690
"visit_terminator_drop \
691
691
loc: {:?} term: {:?} place: {:?} span: {:?}",
692
692
loc, term, place, span
693
693
) ;
694
694
695
+ let write_kind =
696
+ if * replace { WriteKind :: Replace } else { WriteKind :: StorageDeadOrDrop } ;
695
697
self . access_place (
696
698
loc,
697
699
( * place, span) ,
698
- ( AccessDepth :: Drop , Write ( WriteKind :: StorageDeadOrDrop ) ) ,
700
+ ( AccessDepth :: Drop , Write ( write_kind ) ) ,
699
701
LocalMutationIsAllowed :: Yes ,
700
702
flow_state,
701
703
) ;
@@ -885,6 +887,7 @@ enum ReadKind {
885
887
#[ derive( Copy , Clone , PartialEq , Eq , Debug ) ]
886
888
enum WriteKind {
887
889
StorageDeadOrDrop ,
890
+ Replace ,
888
891
MutableBorrow ( BorrowKind ) ,
889
892
Mutate ,
890
893
Move ,
@@ -1132,13 +1135,21 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1132
1135
this. buffer_error ( err) ;
1133
1136
}
1134
1137
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
+ ) ,
1136
1144
WriteKind :: Mutate => {
1137
1145
this. report_illegal_mutation_of_borrowed ( location, place_span, borrow)
1138
1146
}
1139
1147
WriteKind :: Move => {
1140
1148
this. report_move_out_while_borrowed ( location, place_span, borrow)
1141
1149
}
1150
+ WriteKind :: Replace => {
1151
+ this. report_illegal_mutation_of_borrowed ( location, place_span, borrow)
1152
+ }
1142
1153
}
1143
1154
Control :: Break
1144
1155
}
@@ -1982,12 +1993,14 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1982
1993
1983
1994
Reservation (
1984
1995
WriteKind :: Move
1996
+ | WriteKind :: Replace
1985
1997
| WriteKind :: StorageDeadOrDrop
1986
1998
| WriteKind :: MutableBorrow ( BorrowKind :: Shared )
1987
1999
| WriteKind :: MutableBorrow ( BorrowKind :: Shallow ) ,
1988
2000
)
1989
2001
| Write (
1990
2002
WriteKind :: Move
2003
+ | WriteKind :: Replace
1991
2004
| WriteKind :: StorageDeadOrDrop
1992
2005
| WriteKind :: MutableBorrow ( BorrowKind :: Shared )
1993
2006
| WriteKind :: MutableBorrow ( BorrowKind :: Shallow ) ,
0 commit comments