@@ -64,7 +64,19 @@ fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> Body<'
6464
6565 build_call_shim ( tcx, instance, Some ( Adjustment :: RefMut ) , CallKind :: Direct ( call_mut) )
6666 }
67- ty:: InstanceDef :: DropGlue ( def_id, ty) => build_drop_shim ( tcx, def_id, ty) ,
67+
68+ ty:: InstanceDef :: DropGlue ( def_id, ty) => {
69+ // FIXME(#91576): Drop shims for generators aren't subject to the MIR passes at the end
70+ // of this function. Is this intentional?
71+ if let Some ( ty:: Generator ( gen_def_id, substs, _) ) = ty. map ( ty:: TyS :: kind) {
72+ let body = tcx. optimized_mir ( * gen_def_id) . generator_drop ( ) . unwrap ( ) ;
73+ let body = body. clone ( ) . subst ( tcx, substs) ;
74+ debug ! ( "make_shim({:?}) = {:?}" , instance, body) ;
75+ return body;
76+ }
77+
78+ build_drop_shim ( tcx, def_id, ty)
79+ }
6880 ty:: InstanceDef :: CloneShim ( def_id, ty) => build_clone_shim ( tcx, def_id, ty) ,
6981 ty:: InstanceDef :: Virtual ( ..) => {
7082 bug ! ( "InstanceDef::Virtual ({:?}) is for direct calls only" , instance)
@@ -75,14 +87,6 @@ fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> Body<'
7587 } ;
7688 debug ! ( "make_shim({:?}) = untransformed {:?}" , instance, result) ;
7789
78- // In some of the above cases, we seem to be invoking the passes for non-shim MIR bodies.
79- // If that happens, there's no need to run them again.
80- //
81- // FIXME: Is this intentional?
82- if result. phase >= MirPhase :: Const {
83- return result;
84- }
85-
8690 pm:: run_passes (
8791 tcx,
8892 & mut result,
@@ -140,11 +144,7 @@ fn local_decls_for_sig<'tcx>(
140144fn build_drop_shim < ' tcx > ( tcx : TyCtxt < ' tcx > , def_id : DefId , ty : Option < Ty < ' tcx > > ) -> Body < ' tcx > {
141145 debug ! ( "build_drop_shim(def_id={:?}, ty={:?})" , def_id, ty) ;
142146
143- // Check if this is a generator, if so, return the drop glue for it
144- if let Some ( & ty:: Generator ( gen_def_id, substs, _) ) = ty. map ( |ty| ty. kind ( ) ) {
145- let body = tcx. optimized_mir ( gen_def_id) . generator_drop ( ) . unwrap ( ) ;
146- return body. clone ( ) . subst ( tcx, substs) ;
147- }
147+ assert ! ( !matches!( ty, Some ( ty) if ty. is_generator( ) ) ) ;
148148
149149 let substs = if let Some ( ty) = ty {
150150 tcx. intern_substs ( & [ ty. into ( ) ] )
0 commit comments