@@ -984,30 +984,20 @@ where
984984 let ( mplace, size) = match place. place {
985985 Place :: Local { frame, local } => {
986986 match self . stack [ frame] . locals [ local] . access_mut ( ) ? {
987- Ok ( local_val) => {
987+ Ok ( & mut local_val) => {
988988 // 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- } ;
1000989
1001990 // We need the layout of the local. We can NOT use the layout we got,
1002991 // that might e.g., be an inner field of a struct with `Scalar` layout,
1003992 // that has different alignment than the outer field.
1004- // We also need to support unsized types, and hence cannot use `allocate`.
1005993 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`.
1006996 let ( size, align) = self . size_and_align_of ( meta, local_layout) ?
1007997 . expect ( "Cannot allocate for non-dyn-sized type" ) ;
1008998 let ptr = self . memory . allocate ( size, align, MemoryKind :: Stack ) ;
1009999 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 {
10111001 // Preserve old value.
10121002 // We don't have to validate as we can assume the local
10131003 // was already valid for its type.
0 commit comments