@@ -142,6 +142,7 @@ impl<'a, 'tcx> ConstCx<'a, 'tcx> {
142
142
#[ derive( Copy , Clone , Debug ) ]
143
143
enum ValueSource < ' a , ' tcx > {
144
144
Rvalue ( & ' a Rvalue < ' tcx > ) ,
145
+ DropAndReplace ( & ' a Operand < ' tcx > ) ,
145
146
Call {
146
147
callee : & ' a Operand < ' tcx > ,
147
148
args : & ' a [ Operand < ' tcx > ] ,
@@ -298,6 +299,7 @@ trait Qualif {
298
299
fn in_value ( cx : & ConstCx < ' _ , ' tcx > , source : ValueSource < ' _ , ' tcx > ) -> bool {
299
300
match source {
300
301
ValueSource :: Rvalue ( rvalue) => Self :: in_rvalue ( cx, rvalue) ,
302
+ ValueSource :: DropAndReplace ( source) => Self :: in_operand ( cx, source) ,
301
303
ValueSource :: Call { callee, args, return_ty } => {
302
304
Self :: in_call ( cx, callee, args, return_ty)
303
305
}
@@ -889,6 +891,7 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
889
891
let target = match body[ bb] . terminator ( ) . kind {
890
892
TerminatorKind :: Goto { target } |
891
893
TerminatorKind :: Drop { target, .. } |
894
+ TerminatorKind :: DropAndReplace { target, .. } |
892
895
TerminatorKind :: Assert { target, .. } |
893
896
TerminatorKind :: Call { destination : Some ( ( _, target) ) , .. } => {
894
897
Some ( target)
@@ -900,7 +903,6 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
900
903
}
901
904
902
905
TerminatorKind :: SwitchInt { ..} |
903
- TerminatorKind :: DropAndReplace { .. } |
904
906
TerminatorKind :: Resume |
905
907
TerminatorKind :: Abort |
906
908
TerminatorKind :: GeneratorDrop |
@@ -1393,8 +1395,15 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
1393
1395
for arg in args {
1394
1396
self . visit_operand ( arg, location) ;
1395
1397
}
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
+ }
1398
1407
1399
1408
// Deny *any* live drops anywhere other than functions.
1400
1409
if self . mode . requires_const_checking ( ) {
@@ -1423,6 +1432,14 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
1423
1432
}
1424
1433
}
1425
1434
}
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
+ }
1426
1443
} else {
1427
1444
// Qualify any operands inside other terminators.
1428
1445
self . super_terminator_kind ( kind, location) ;
0 commit comments