@@ -17,6 +17,7 @@ use rustc::mir::interpret::{
1717 GlobalId , Value , Pointer , PrimVal , PrimValKind ,
1818 EvalError , EvalResult , EvalErrorKind , MemoryPointer ,
1919} ;
20+ use std:: mem;
2021
2122use super :: { Place , PlaceExtra , Memory ,
2223 HasMemory , MemoryKind ,
@@ -1704,20 +1705,17 @@ impl<'mir, 'tcx> Frame<'mir, 'tcx> {
17041705 }
17051706 }
17061707
1707- pub fn storage_live ( & mut self , local : mir:: Local ) -> EvalResult < ' tcx , Option < Value > > {
1708+ pub fn storage_live ( & mut self , local : mir:: Local ) -> Option < Value > {
17081709 trace ! ( "{:?} is now live" , local) ;
17091710
1710- let old = self . locals [ local] ;
1711- self . locals [ local] = Some ( Value :: ByVal ( PrimVal :: Undef ) ) ; // StorageLive *always* kills the value that's currently stored
1712- return Ok ( old) ;
1711+ // StorageLive *always* kills the value that's currently stored
1712+ mem:: replace ( & mut self . locals [ local] , Some ( Value :: ByVal ( PrimVal :: Undef ) ) )
17131713 }
17141714
17151715 /// Returns the old value of the local
1716- pub fn storage_dead ( & mut self , local : mir:: Local ) -> EvalResult < ' tcx , Option < Value > > {
1716+ pub fn storage_dead ( & mut self , local : mir:: Local ) -> Option < Value > {
17171717 trace ! ( "{:?} is now dead" , local) ;
17181718
1719- let old = self . locals [ local] ;
1720- self . locals [ local] = None ;
1721- return Ok ( old) ;
1719+ self . locals [ local] . take ( )
17221720 }
17231721}
0 commit comments