@@ -101,9 +101,6 @@ fn has_significant_drop_raw<'tcx>(
101
101
struct NeedsDropTypes < ' tcx , F > {
102
102
tcx : TyCtxt < ' tcx > ,
103
103
typing_env : ty:: TypingEnv < ' tcx > ,
104
- /// Whether to reveal coroutine witnesses, this is set
105
- /// to `false` unless we compute `needs_drop` for a coroutine witness.
106
- reveal_coroutine_witnesses : bool ,
107
104
query_ty : Ty < ' tcx > ,
108
105
seen_tys : FxHashSet < Ty < ' tcx > > ,
109
106
/// A stack of types left to process, and the recursion depth when we
@@ -131,7 +128,6 @@ impl<'tcx, F> NeedsDropTypes<'tcx, F> {
131
128
Self {
132
129
tcx,
133
130
typing_env,
134
- reveal_coroutine_witnesses : exhaustive,
135
131
seen_tys,
136
132
query_ty : ty,
137
133
unchecked_tys : vec ! [ ( ty, 0 ) ] ,
@@ -195,23 +191,26 @@ where
195
191
// for the coroutine witness and check whether any of the contained types
196
192
// need to be dropped, and only require the captured types to be live
197
193
// if they do.
198
- ty:: Coroutine ( _, args) => {
199
- if self . reveal_coroutine_witnesses {
200
- queue_type ( self , args. as_coroutine ( ) . witness ( ) ) ;
194
+ ty:: Coroutine ( def_id, args) => {
195
+ if self . exhaustive {
196
+ for upvar in args. as_coroutine ( ) . upvar_tys ( ) {
197
+ queue_type ( self , upvar) ;
198
+ }
199
+ queue_type ( self , args. as_coroutine ( ) . resume_ty ( ) ) ;
200
+ if let Some ( witness) = tcx. mir_coroutine_witnesses ( def_id) {
201
+ for field_ty in & witness. field_tys {
202
+ queue_type (
203
+ self ,
204
+ EarlyBinder :: bind ( field_ty. ty ) . instantiate ( tcx, args) ,
205
+ ) ;
206
+ }
207
+ }
201
208
} else {
202
209
return Some ( self . always_drop_component ( ty) ) ;
203
210
}
204
211
}
205
- ty:: CoroutineWitness ( def_id, args) => {
206
- if let Some ( witness) = tcx. mir_coroutine_witnesses ( def_id) {
207
- self . reveal_coroutine_witnesses = true ;
208
- for field_ty in & witness. field_tys {
209
- queue_type (
210
- self ,
211
- EarlyBinder :: bind ( field_ty. ty ) . instantiate ( tcx, args) ,
212
- ) ;
213
- }
214
- }
212
+ ty:: CoroutineWitness ( ..) => {
213
+ unreachable ! ( "witness should be handled in parent" ) ;
215
214
}
216
215
217
216
ty:: UnsafeBinder ( bound_ty) => {
0 commit comments