@@ -51,7 +51,7 @@ pub(super) fn build_async_drop_shim<'tcx>(
5151 let typing_env = ty:: TypingEnv :: fully_monomorphized ( ) ;
5252
5353 let drop_ty = parent_args. first ( ) . unwrap ( ) . expect_ty ( ) ;
54- let drop_ptr_ty = Ty :: new_mut_ptr ( tcx, drop_ty) ;
54+ let drop_ptr_ty = Ty :: new_mut_ref ( tcx, tcx . lifetimes . re_erased , drop_ty) ;
5555
5656 assert ! ( tcx. is_coroutine( def_id) ) ;
5757 let coroutine_kind = tcx. coroutine_kind ( def_id) . unwrap ( ) ;
@@ -209,7 +209,7 @@ fn build_adrop_for_coroutine_shim<'tcx>(
209209 let source_info = SourceInfo :: outermost ( span) ;
210210 // converting `(_1: Pin<&mut CorLayout>, _2: &mut Context<'_>) -> Poll<()>`
211211 // into `(_1: Pin<&mut ProxyLayout>, _2: &mut Context<'_>) -> Poll<()>`
212- // let mut _x: &mut CorLayout = &*_1.0.0;
212+ // let mut _x: &mut CorLayout = &mut *_1.0.0;
213213 // Replace old _1.0 accesses into _x accesses;
214214 let body = tcx. optimized_mir ( * coroutine_def_id) . future_drop_poll ( ) . unwrap ( ) ;
215215 let mut body: Body < ' tcx > = EarlyBinder :: bind ( body. clone ( ) ) . instantiate ( tcx, impl_args) ;
@@ -231,7 +231,7 @@ fn build_adrop_for_coroutine_shim<'tcx>(
231231
232232 {
233233 let mut idx: usize = 0 ;
234- // _proxy = _1.0 : Pin<&ProxyLayout> ==> &ProxyLayout
234+ // _proxy = _1.0 : Pin<&mut ProxyLayout> ==> &mut ProxyLayout
235235 let proxy_ref_place = Place :: from ( pin_proxy_layout_local)
236236 . project_deeper ( & [ PlaceElem :: Field ( FieldIdx :: ZERO , proxy_ref) ] , tcx) ;
237237 body. basic_blocks_mut ( ) [ START_BLOCK ] . statements . insert (
@@ -245,22 +245,23 @@ fn build_adrop_for_coroutine_shim<'tcx>(
245245 ) ,
246246 ) ;
247247 idx += 1 ;
248- let mut cor_ptr_local = proxy_ref_local;
248+
249+ // _cor_ref_tmp = (*(*_proxy).0).0...
250+ let mut cor_ref_tmp_local = proxy_ref_local;
249251 proxy_ty. find_async_drop_impl_coroutine ( tcx, |ty| {
250252 if ty != proxy_ty {
251- let ty_ptr = Ty :: new_mut_ptr ( tcx, ty) ;
252- let impl_ptr_place = Place :: from ( cor_ptr_local ) . project_deeper (
253- & [ PlaceElem :: Deref , PlaceElem :: Field ( FieldIdx :: ZERO , ty_ptr ) ] ,
253+ let ty_ref = Ty :: new_mut_ref ( tcx, tcx . lifetimes . re_erased , ty) ;
254+ let impl_ptr_place = Place :: from ( cor_ref_tmp_local ) . project_deeper (
255+ & [ PlaceElem :: Deref , PlaceElem :: Field ( FieldIdx :: ZERO , ty_ref ) ] ,
254256 tcx,
255257 ) ;
256- cor_ptr_local = body. local_decls . push ( LocalDecl :: new ( ty_ptr, span) ) ;
257- // _cor_ptr = _proxy.0.0 (... .0)
258+ cor_ref_tmp_local = body. local_decls . push ( LocalDecl :: new ( ty_ref, span) ) ;
258259 body. basic_blocks_mut ( ) [ START_BLOCK ] . statements . insert (
259260 idx,
260261 Statement :: new (
261262 source_info,
262263 StatementKind :: Assign ( Box :: new ( (
263- Place :: from ( cor_ptr_local ) ,
264+ Place :: from ( cor_ref_tmp_local ) ,
264265 Rvalue :: Use ( Operand :: Copy ( impl_ptr_place) ) ,
265266 ) ) ) ,
266267 ) ,
@@ -269,17 +270,15 @@ fn build_adrop_for_coroutine_shim<'tcx>(
269270 }
270271 } ) ;
271272
272- // _cor_ref = &*cor_ptr
273- let reborrow = Rvalue :: Ref (
274- tcx. lifetimes . re_erased ,
275- BorrowKind :: Mut { kind : MutBorrowKind :: Default } ,
276- tcx. mk_place_deref ( Place :: from ( cor_ptr_local) ) ,
277- ) ;
273+ // _cor_ref = cor_ref_tmp
278274 body. basic_blocks_mut ( ) [ START_BLOCK ] . statements . insert (
279275 idx,
280276 Statement :: new (
281277 source_info,
282- StatementKind :: Assign ( Box :: new ( ( Place :: from ( cor_ref_local) , reborrow) ) ) ,
278+ StatementKind :: Assign ( Box :: new ( (
279+ Place :: from ( cor_ref_local) ,
280+ Rvalue :: Use ( Operand :: Move ( Place :: from ( cor_ref_tmp_local) ) ) ,
281+ ) ) ) ,
283282 ) ,
284283 ) ;
285284 }
@@ -341,7 +340,7 @@ fn build_adrop_for_adrop_shim<'tcx>(
341340 let mut cor_ptr_local = proxy_ref_local;
342341 proxy_ty. find_async_drop_impl_coroutine ( tcx, |ty| {
343342 if ty != proxy_ty {
344- let ty_ptr = Ty :: new_mut_ptr ( tcx, ty) ;
343+ let ty_ptr = Ty :: new_mut_ref ( tcx, tcx . lifetimes . re_erased , ty) ;
345344 let impl_ptr_place = Place :: from ( cor_ptr_local)
346345 . project_deeper ( & [ PlaceElem :: Deref , PlaceElem :: Field ( FieldIdx :: ZERO , ty_ptr) ] , tcx) ;
347346 cor_ptr_local = locals. push ( LocalDecl :: new ( ty_ptr, span) ) ;
0 commit comments