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