@@ -330,11 +330,19 @@ pub enum TerminatorKind<'tcx> {
330
330
331
331
/// Drop the Lvalue
332
332
Drop {
333
- value : Lvalue < ' tcx > ,
333
+ location : Lvalue < ' tcx > ,
334
334
target : BasicBlock ,
335
335
unwind : Option < BasicBlock >
336
336
} ,
337
337
338
+ /// Drop the Lvalue and assign the new value over it
339
+ DropAndReplace {
340
+ location : Lvalue < ' tcx > ,
341
+ value : Operand < ' tcx > ,
342
+ target : BasicBlock ,
343
+ unwind : Option < BasicBlock > ,
344
+ } ,
345
+
338
346
/// Block ends with a call of a converging function
339
347
Call {
340
348
/// The function that’s being called
@@ -373,8 +381,14 @@ impl<'tcx> TerminatorKind<'tcx> {
373
381
slice:: ref_slice ( t) . into_cow ( ) ,
374
382
Call { destination : None , cleanup : Some ( ref c) , .. } => slice:: ref_slice ( c) . into_cow ( ) ,
375
383
Call { destination : None , cleanup : None , .. } => ( & [ ] ) . into_cow ( ) ,
376
- Drop { target, unwind : Some ( unwind) , .. } => vec ! [ target, unwind] . into_cow ( ) ,
377
- Drop { ref target, .. } => slice:: ref_slice ( target) . into_cow ( ) ,
384
+ DropAndReplace { target, unwind : Some ( unwind) , .. } |
385
+ Drop { target, unwind : Some ( unwind) , .. } => {
386
+ vec ! [ target, unwind] . into_cow ( )
387
+ }
388
+ DropAndReplace { ref target, unwind : None , .. } |
389
+ Drop { ref target, unwind : None , .. } => {
390
+ slice:: ref_slice ( target) . into_cow ( )
391
+ }
378
392
}
379
393
}
380
394
@@ -393,8 +407,12 @@ impl<'tcx> TerminatorKind<'tcx> {
393
407
Call { destination : Some ( ( _, ref mut t) ) , cleanup : None , .. } => vec ! [ t] ,
394
408
Call { destination : None , cleanup : Some ( ref mut c) , .. } => vec ! [ c] ,
395
409
Call { destination : None , cleanup : None , .. } => vec ! [ ] ,
410
+ DropAndReplace { ref mut target, unwind : Some ( ref mut unwind) , .. } |
396
411
Drop { ref mut target, unwind : Some ( ref mut unwind) , .. } => vec ! [ target, unwind] ,
397
- Drop { ref mut target, .. } => vec ! [ target]
412
+ DropAndReplace { ref mut target, unwind : None , .. } |
413
+ Drop { ref mut target, unwind : None , .. } => {
414
+ vec ! [ target]
415
+ }
398
416
}
399
417
}
400
418
}
@@ -461,7 +479,9 @@ impl<'tcx> TerminatorKind<'tcx> {
461
479
SwitchInt { discr : ref lv, .. } => write ! ( fmt, "switchInt({:?})" , lv) ,
462
480
Return => write ! ( fmt, "return" ) ,
463
481
Resume => write ! ( fmt, "resume" ) ,
464
- Drop { ref value, .. } => write ! ( fmt, "drop({:?})" , value) ,
482
+ Drop { ref location, .. } => write ! ( fmt, "drop({:?})" , location) ,
483
+ DropAndReplace { ref location, ref value, .. } =>
484
+ write ! ( fmt, "replace({:?} <- {:?})" , location, value) ,
465
485
Call { ref func, ref args, ref destination, .. } => {
466
486
if let Some ( ( ref destination, _) ) = * destination {
467
487
write ! ( fmt, "{:?} = " , destination) ?;
@@ -506,8 +526,12 @@ impl<'tcx> TerminatorKind<'tcx> {
506
526
Call { destination : Some ( _) , cleanup : None , .. } => vec ! [ "return" . into_cow( ) ] ,
507
527
Call { destination : None , cleanup : Some ( _) , .. } => vec ! [ "unwind" . into_cow( ) ] ,
508
528
Call { destination : None , cleanup : None , .. } => vec ! [ ] ,
529
+ DropAndReplace { unwind : None , .. } |
509
530
Drop { unwind : None , .. } => vec ! [ "return" . into_cow( ) ] ,
510
- Drop { .. } => vec ! [ "return" . into_cow( ) , "unwind" . into_cow( ) ] ,
531
+ DropAndReplace { unwind : Some ( _) , .. } |
532
+ Drop { unwind : Some ( _) , .. } => {
533
+ vec ! [ "return" . into_cow( ) , "unwind" . into_cow( ) ]
534
+ }
511
535
}
512
536
}
513
537
}
@@ -918,7 +942,7 @@ impl<'tcx> Debug for Rvalue<'tcx> {
918
942
ppaux:: parameterized ( fmt, substs, variant_def. did ,
919
943
ppaux:: Ns :: Value , & [ ] ,
920
944
|tcx| {
921
- tcx. lookup_item_type ( variant_def. did ) . generics
945
+ Some ( tcx. lookup_item_type ( variant_def. did ) . generics )
922
946
} ) ?;
923
947
924
948
match variant_def. kind ( ) {
@@ -1010,8 +1034,9 @@ impl<'tcx> Debug for Literal<'tcx> {
1010
1034
use self :: Literal :: * ;
1011
1035
match * self {
1012
1036
Item { def_id, substs } => {
1013
- ppaux:: parameterized ( fmt, substs, def_id, ppaux:: Ns :: Value , & [ ] ,
1014
- |tcx| tcx. lookup_item_type ( def_id) . generics )
1037
+ ppaux:: parameterized (
1038
+ fmt, substs, def_id, ppaux:: Ns :: Value , & [ ] ,
1039
+ |tcx| Some ( tcx. lookup_item_type ( def_id) . generics ) )
1015
1040
}
1016
1041
Value { ref value } => {
1017
1042
write ! ( fmt, "const " ) ?;
0 commit comments