@@ -986,30 +986,20 @@ where
986
986
let ( mplace, size) = match place. place {
987
987
Place :: Local { frame, local } => {
988
988
match self . stack [ frame] . locals [ local] . access_mut ( ) ? {
989
- Ok ( local_val) => {
989
+ Ok ( & mut local_val) => {
990
990
// We need to make an allocation.
991
- // FIXME: Consider not doing anything for a ZST, and just returning
992
- // a fake pointer? Are we even called for ZST?
993
-
994
- // We cannot hold on to the reference `local_val` while allocating,
995
- // but we can hold on to the value in there.
996
- let old_val =
997
- if let LocalValue :: Live ( Operand :: Immediate ( value) ) = * local_val {
998
- Some ( value)
999
- } else {
1000
- None
1001
- } ;
1002
991
1003
992
// We need the layout of the local. We can NOT use the layout we got,
1004
993
// that might e.g., be an inner field of a struct with `Scalar` layout,
1005
994
// that has different alignment than the outer field.
1006
- // We also need to support unsized types, and hence cannot use `allocate`.
1007
995
let local_layout = self . layout_of_local ( & self . stack [ frame] , local, None ) ?;
996
+
997
+ // We also need to support unsized types, and hence cannot use `allocate`.
1008
998
let ( size, align) = self . size_and_align_of ( meta, local_layout) ?
1009
999
. expect ( "Cannot allocate for non-dyn-sized type" ) ;
1010
1000
let ptr = self . memory . allocate ( size, align, MemoryKind :: Stack ) ;
1011
1001
let mplace = MemPlace { ptr : ptr. into ( ) , align, meta } ;
1012
- if let Some ( value) = old_val {
1002
+ if let LocalValue :: Live ( Operand :: Immediate ( value) ) = local_val {
1013
1003
// Preserve old value.
1014
1004
// We don't have to validate as we can assume the local
1015
1005
// was already valid for its type.
0 commit comments