@@ -142,6 +142,7 @@ impl<'a, 'tcx> ConstCx<'a, 'tcx> {
142142#[ derive( Copy , Clone , Debug ) ]
143143enum ValueSource < ' a , ' tcx > {
144144 Rvalue ( & ' a Rvalue < ' tcx > ) ,
145+ DropAndReplace ( & ' a Operand < ' tcx > ) ,
145146 Call {
146147 callee : & ' a Operand < ' tcx > ,
147148 args : & ' a [ Operand < ' tcx > ] ,
@@ -298,6 +299,7 @@ trait Qualif {
298299 fn in_value ( cx : & ConstCx < ' _ , ' tcx > , source : ValueSource < ' _ , ' tcx > ) -> bool {
299300 match source {
300301 ValueSource :: Rvalue ( rvalue) => Self :: in_rvalue ( cx, rvalue) ,
302+ ValueSource :: DropAndReplace ( source) => Self :: in_operand ( cx, source) ,
301303 ValueSource :: Call { callee, args, return_ty } => {
302304 Self :: in_call ( cx, callee, args, return_ty)
303305 }
@@ -889,6 +891,7 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
889891 let target = match body[ bb] . terminator ( ) . kind {
890892 TerminatorKind :: Goto { target } |
891893 TerminatorKind :: Drop { target, .. } |
894+ TerminatorKind :: DropAndReplace { target, .. } |
892895 TerminatorKind :: Assert { target, .. } |
893896 TerminatorKind :: Call { destination : Some ( ( _, target) ) , .. } => {
894897 Some ( target)
@@ -900,7 +903,6 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
900903 }
901904
902905 TerminatorKind :: SwitchInt { ..} |
903- TerminatorKind :: DropAndReplace { .. } |
904906 TerminatorKind :: Resume |
905907 TerminatorKind :: Abort |
906908 TerminatorKind :: GeneratorDrop |
@@ -1393,8 +1395,15 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
13931395 for arg in args {
13941396 self . visit_operand ( arg, location) ;
13951397 }
1396- } else if let TerminatorKind :: Drop { location : ref place, .. } = * kind {
1397- self . super_terminator_kind ( kind, location) ;
1398+ } else if let TerminatorKind :: Drop {
1399+ location : ref place, ..
1400+ } | TerminatorKind :: DropAndReplace {
1401+ location : ref place, ..
1402+ } = * kind {
1403+ match * kind {
1404+ TerminatorKind :: DropAndReplace { .. } => { }
1405+ _ => self . super_terminator_kind ( kind, location) ,
1406+ }
13981407
13991408 // Deny *any* live drops anywhere other than functions.
14001409 if self . mode . requires_const_checking ( ) {
@@ -1423,6 +1432,14 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
14231432 }
14241433 }
14251434 }
1435+
1436+ match * kind {
1437+ TerminatorKind :: DropAndReplace { ref value, .. } => {
1438+ self . assign ( place, ValueSource :: DropAndReplace ( value) , location) ;
1439+ self . visit_operand ( value, location) ;
1440+ }
1441+ _ => { }
1442+ }
14261443 } else {
14271444 // Qualify any operands inside other terminators.
14281445 self . super_terminator_kind ( kind, location) ;
0 commit comments