@@ -974,31 +974,20 @@ where
974974 let ( mplace, size) = match place. place {
975975 Place :: Local { frame, local } => {
976976 match self . stack [ frame] . locals [ local] . access_mut ( ) ? {
977- Ok ( local_val) => {
977+ Ok ( & mut local_val) => {
978978 // We need to make an allocation.
979- // FIXME: Consider not doing anything for a ZST, and just returning
980- // a fake pointer? Are we even called for ZST?
981-
982- // We cannot hold on to the reference `local_val` while allocating,
983- // but we can hold on to the value in there.
984- let old_val =
985- if let LocalValue :: Live ( Operand :: Immediate ( value) ) = * local_val {
986- Some ( value)
987- } else {
988- None
989- } ;
990979
991980 // We need the layout of the local. We can NOT use the layout we got,
992981 // that might e.g., be an inner field of a struct with `Scalar` layout,
993982 // that has different alignment than the outer field.
994- // We also need to support unsized types, and hence cannot use `allocate`.
995983 let local_layout = self . layout_of_local ( & self . stack [ frame] , local, None ) ?;
984+ // We also need to support unsized types, and hence cannot use `allocate`.
996985 let ( size, align) = self
997986 . size_and_align_of ( meta, local_layout) ?
998987 . expect ( "Cannot allocate for non-dyn-sized type" ) ;
999988 let ptr = self . memory . allocate ( size, align, MemoryKind :: Stack ) ;
1000989 let mplace = MemPlace { ptr : ptr. into ( ) , align, meta } ;
1001- if let Some ( value) = old_val {
990+ if let LocalValue :: Live ( Operand :: Immediate ( value) ) = local_val {
1002991 // Preserve old value.
1003992 // We don't have to validate as we can assume the local
1004993 // was already valid for its type.
0 commit comments