@@ -17,6 +17,7 @@ use rustc::mir::interpret::{
17
17
GlobalId , Value , Pointer , PrimVal , PrimValKind ,
18
18
EvalError , EvalResult , EvalErrorKind , MemoryPointer ,
19
19
} ;
20
+ use std:: mem;
20
21
21
22
use super :: { Place , PlaceExtra , Memory ,
22
23
HasMemory , MemoryKind ,
@@ -1704,20 +1705,17 @@ impl<'mir, 'tcx> Frame<'mir, 'tcx> {
1704
1705
}
1705
1706
}
1706
1707
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 > {
1708
1709
trace ! ( "{:?} is now live" , local) ;
1709
1710
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 ) ) )
1713
1713
}
1714
1714
1715
1715
/// 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 > {
1717
1717
trace ! ( "{:?} is now dead" , local) ;
1718
1718
1719
- let old = self . locals [ local] ;
1720
- self . locals [ local] = None ;
1721
- return Ok ( old) ;
1719
+ self . locals [ local] . take ( )
1722
1720
}
1723
1721
}
0 commit comments