@@ -916,7 +916,15 @@ fn compute_layout<'tcx>(
916916 let mut tys = IndexVec :: < GeneratorSavedLocal , _ > :: new ( ) ;
917917 for ( saved_local, local) in saved_locals. iter_enumerated ( ) {
918918 locals. push ( local) ;
919- tys. push ( body. local_decls [ local] . ty ) ;
919+ let decl = & body. local_decls [ local] ;
920+ let decl = GeneratorSavedTy {
921+ ty : decl. ty ,
922+ source_info : decl. source_info ,
923+ is_static_ptr : decl. internal
924+ && decl. ty . is_unsafe_ptr ( )
925+ && matches ! ( decl. local_info. as_deref( ) , Some ( LocalInfo :: StaticRef { .. } ) ) ,
926+ } ;
927+ tys. push ( decl) ;
920928 debug ! ( "generator saved local {:?} => {:?}" , saved_local, local) ;
921929 }
922930
@@ -947,7 +955,7 @@ fn compute_layout<'tcx>(
947955 // just use the first one here. That's fine; fields do not move
948956 // around inside generators, so it doesn't matter which variant
949957 // index we access them by.
950- remap. entry ( locals[ saved_local] ) . or_insert ( ( tys[ saved_local] , variant_index, idx) ) ;
958+ remap. entry ( locals[ saved_local] ) . or_insert ( ( tys[ saved_local] . ty , variant_index, idx) ) ;
951959 }
952960 variant_fields. push ( fields) ;
953961 variant_source_info. push ( source_info_at_suspension_points[ suspension_point_idx] ) ;
@@ -957,6 +965,7 @@ fn compute_layout<'tcx>(
957965
958966 let layout =
959967 GeneratorLayout { field_tys : tys, variant_fields, variant_source_info, storage_conflicts } ;
968+ debug ! ( ?layout) ;
960969
961970 ( remap, layout, storage_liveness)
962971}
0 commit comments