@@ -298,35 +298,17 @@ fn local_decls_for_sig<'tcx>(
298298fn dropee_emit_retag < ' tcx > (
299299 tcx : TyCtxt < ' tcx > ,
300300 body : & mut Body < ' tcx > ,
301- mut dropee_ptr : Place < ' tcx > ,
301+ dropee_ptr : Place < ' tcx > ,
302302 span : Span ,
303- ) -> Place < ' tcx > {
303+ ) {
304304 if tcx. sess . opts . unstable_opts . mir_emit_retag {
305305 let source_info = SourceInfo :: outermost ( span) ;
306- // We want to treat the function argument as if it was passed by `&mut`. As such, we
307- // generate
308- // ```
309- // temp = &mut *arg;
310- // Retag(temp, FnEntry)
311- // ```
312- // It's important that we do this first, before anything that depends on `dropee_ptr`
313- // has been put into the body.
314- let reborrow = Rvalue :: Ref (
315- tcx. lifetimes . re_erased ,
316- BorrowKind :: Mut { kind : MutBorrowKind :: Default } ,
317- tcx. mk_place_deref ( dropee_ptr) ,
318- ) ;
319- let ref_ty = reborrow. ty ( body. local_decls ( ) , tcx) ;
320- dropee_ptr = body. local_decls . push ( LocalDecl :: new ( ref_ty, span) ) . into ( ) ;
321- let new_statements = [
322- StatementKind :: Assign ( Box :: new ( ( dropee_ptr, reborrow) ) ) ,
323- StatementKind :: Retag ( RetagKind :: FnEntry , Box :: new ( dropee_ptr) ) ,
324- ] ;
325- for s in new_statements {
326- body. basic_blocks_mut ( ) [ START_BLOCK ] . statements . push ( Statement :: new ( source_info, s) ) ;
327- }
306+ let new_statement = StatementKind :: Retag ( RetagKind :: FnEntry , Box :: new ( dropee_ptr) ) ;
307+
308+ body. basic_blocks_mut ( ) [ START_BLOCK ]
309+ . statements
310+ . push ( Statement :: new ( source_info, new_statement) ) ;
328311 }
329- dropee_ptr
330312}
331313
332314fn build_drop_shim < ' tcx > ( tcx : TyCtxt < ' tcx > , def_id : DefId , ty : Option < Ty < ' tcx > > ) -> Body < ' tcx > {
@@ -359,7 +341,7 @@ fn build_drop_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, ty: Option<Ty<'tcx>>)
359341
360342 // The first argument (index 0), but add 1 for the return value.
361343 let dropee_ptr = Place :: from ( Local :: new ( 1 + 0 ) ) ;
362- let dropee_ptr = dropee_emit_retag ( tcx, & mut body, dropee_ptr, span) ;
344+ dropee_emit_retag ( tcx, & mut body, dropee_ptr, span) ;
363345
364346 if ty. is_some ( ) {
365347 let patch = {
0 commit comments