@@ -64,7 +64,19 @@ fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> Body<'
64
64
65
65
build_call_shim ( tcx, instance, Some ( Adjustment :: RefMut ) , CallKind :: Direct ( call_mut) )
66
66
}
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
+ }
68
80
ty:: InstanceDef :: CloneShim ( def_id, ty) => build_clone_shim ( tcx, def_id, ty) ,
69
81
ty:: InstanceDef :: Virtual ( ..) => {
70
82
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<'
75
87
} ;
76
88
debug ! ( "make_shim({:?}) = untransformed {:?}" , instance, result) ;
77
89
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
-
86
90
pm:: run_passes (
87
91
tcx,
88
92
& mut result,
@@ -140,11 +144,7 @@ fn local_decls_for_sig<'tcx>(
140
144
fn build_drop_shim < ' tcx > ( tcx : TyCtxt < ' tcx > , def_id : DefId , ty : Option < Ty < ' tcx > > ) -> Body < ' tcx > {
141
145
debug ! ( "build_drop_shim(def_id={:?}, ty={:?})" , def_id, ty) ;
142
146
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( ) ) ) ;
148
148
149
149
let substs = if let Some ( ty) = ty {
150
150
tcx. intern_substs ( & [ ty. into ( ) ] )
0 commit comments