@@ -199,16 +199,11 @@ fn drop_tys_helper<'tcx>(
199
199
fn with_query_cache < ' tcx > (
200
200
tcx : TyCtxt < ' tcx > ,
201
201
iter : impl IntoIterator < Item = Ty < ' tcx > > ,
202
- only_significant : bool ,
203
202
) -> NeedsDropResult < Vec < Ty < ' tcx > > > {
204
203
iter. into_iter ( ) . try_fold ( Vec :: new ( ) , |mut vec, subty| {
205
204
match subty. kind ( ) {
206
205
ty:: Adt ( adt_id, subst) => {
207
- for subty in if only_significant {
208
- tcx. adt_significant_drop_tys ( adt_id. did ) ?
209
- } else {
210
- tcx. adt_drop_tys ( adt_id. did ) ?
211
- } {
206
+ for subty in tcx. adt_drop_tys ( adt_id. did ) ? {
212
207
vec. push ( subty. subst ( tcx, subst) ) ;
213
208
}
214
209
}
@@ -234,25 +229,28 @@ fn drop_tys_helper<'tcx>(
234
229
// Since the destructor is insignificant, we just want to make sure all of
235
230
// the passed in type parameters are also insignificant.
236
231
// Eg: Vec<T> dtor is insignificant when T=i32 but significant when T=Mutex.
237
- with_query_cache ( tcx , substs. types ( ) , only_significant )
232
+ Ok ( substs. types ( ) . collect ( ) )
238
233
}
239
234
}
240
235
} else if adt_def. is_union ( ) {
241
236
debug ! ( "drop_tys_helper: `{:?}` is a union" , adt_def) ;
242
237
Ok ( Vec :: new ( ) )
243
238
} else {
244
- with_query_cache (
245
- tcx,
246
- adt_def. all_fields ( ) . map ( |field| {
247
- let r = tcx. type_of ( field. did ) . subst ( tcx, substs) ;
248
- debug ! (
249
- "drop_tys_helper: Subst into {:?} with {:?} gettng {:?}" ,
250
- field, substs, r
251
- ) ;
252
- r
253
- } ) ,
254
- only_significant,
255
- )
239
+ let field_tys = adt_def. all_fields ( ) . map ( |field| {
240
+ let r = tcx. type_of ( field. did ) . subst ( tcx, substs) ;
241
+ debug ! ( "drop_tys_helper: Subst into {:?} with {:?} gettng {:?}" , field, substs, r) ;
242
+ r
243
+ } ) ;
244
+ if only_significant {
245
+ // We can't recurse through the query system here because we might induce a cycle
246
+ Ok ( field_tys. collect ( ) )
247
+ } else {
248
+ // We can use the query system if we consider all drops significant. In that case,
249
+ // ADTs are `needs_drop` exactly if they `impl Drop` or if any of their "transitive"
250
+ // fields do. There can be no cycles here, because ADTs cannot contain themselves as
251
+ // fields.
252
+ with_query_cache ( tcx, field_tys)
253
+ }
256
254
}
257
255
. map ( |v| v. into_iter ( ) )
258
256
} ;
0 commit comments