@@ -330,11 +330,19 @@ pub enum TerminatorKind<'tcx> {
330330
331331 /// Drop the Lvalue
332332 Drop {
333- value : Lvalue < ' tcx > ,
333+ location : Lvalue < ' tcx > ,
334334 target : BasicBlock ,
335335 unwind : Option < BasicBlock >
336336 } ,
337337
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+
338346 /// Block ends with a call of a converging function
339347 Call {
340348 /// The function that’s being called
@@ -373,8 +381,14 @@ impl<'tcx> TerminatorKind<'tcx> {
373381 slice:: ref_slice ( t) . into_cow ( ) ,
374382 Call { destination : None , cleanup : Some ( ref c) , .. } => slice:: ref_slice ( c) . into_cow ( ) ,
375383 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+ }
378392 }
379393 }
380394
@@ -393,8 +407,12 @@ impl<'tcx> TerminatorKind<'tcx> {
393407 Call { destination : Some ( ( _, ref mut t) ) , cleanup : None , .. } => vec ! [ t] ,
394408 Call { destination : None , cleanup : Some ( ref mut c) , .. } => vec ! [ c] ,
395409 Call { destination : None , cleanup : None , .. } => vec ! [ ] ,
410+ DropAndReplace { ref mut target, unwind : Some ( ref mut unwind) , .. } |
396411 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+ }
398416 }
399417 }
400418}
@@ -461,7 +479,9 @@ impl<'tcx> TerminatorKind<'tcx> {
461479 SwitchInt { discr : ref lv, .. } => write ! ( fmt, "switchInt({:?})" , lv) ,
462480 Return => write ! ( fmt, "return" ) ,
463481 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) ,
465485 Call { ref func, ref args, ref destination, .. } => {
466486 if let Some ( ( ref destination, _) ) = * destination {
467487 write ! ( fmt, "{:?} = " , destination) ?;
@@ -506,8 +526,12 @@ impl<'tcx> TerminatorKind<'tcx> {
506526 Call { destination : Some ( _) , cleanup : None , .. } => vec ! [ "return" . into_cow( ) ] ,
507527 Call { destination : None , cleanup : Some ( _) , .. } => vec ! [ "unwind" . into_cow( ) ] ,
508528 Call { destination : None , cleanup : None , .. } => vec ! [ ] ,
529+ DropAndReplace { unwind : None , .. } |
509530 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+ }
511535 }
512536 }
513537}
@@ -918,7 +942,7 @@ impl<'tcx> Debug for Rvalue<'tcx> {
918942 ppaux:: parameterized ( fmt, substs, variant_def. did ,
919943 ppaux:: Ns :: Value , & [ ] ,
920944 |tcx| {
921- tcx. lookup_item_type ( variant_def. did ) . generics
945+ Some ( tcx. lookup_item_type ( variant_def. did ) . generics )
922946 } ) ?;
923947
924948 match variant_def. kind ( ) {
@@ -1010,8 +1034,9 @@ impl<'tcx> Debug for Literal<'tcx> {
10101034 use self :: Literal :: * ;
10111035 match * self {
10121036 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 ) )
10151040 }
10161041 Value { ref value } => {
10171042 write ! ( fmt, "const " ) ?;
0 commit comments