Skip to content

Commit a78c1c2

Browse files
dingxiangfei2009ehuss
authored andcommitted
let the query recurse through coroutine
1 parent 94790bd commit a78c1c2

File tree

3 files changed

+16
-21
lines changed

3 files changed

+16
-21
lines changed

compiler/rustc_middle/src/query/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1456,7 +1456,7 @@ rustc_queries! {
14561456
/// *IMPORTANT*: *DO NOT* run this query before promoted MIR body is constructed,
14571457
/// because this query partially depends on that query.
14581458
/// Otherwise, there is a risk of query cycles.
1459-
query list_significant_drop_tys(ty: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> Result<&'tcx ty::List<Ty<'tcx>>, AlwaysRequiresDrop> {
1459+
query list_significant_drop_tys(ty: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> &'tcx ty::List<Ty<'tcx>> {
14601460
desc { |tcx| "computing when `{}` has a significant destructor", ty.value }
14611461
cache_on_disk_if { false }
14621462
}

compiler/rustc_mir_transform/src/lint_tail_expr_drop_order.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -149,25 +149,11 @@ fn extract_component_raw<'tcx>(
149149
// Droppiness does not depend on regions, so let us erase them.
150150
let ty = tcx.try_normalize_erasing_regions(param_env, ty).unwrap_or(ty);
151151

152-
let Ok(tys) = tcx.list_significant_drop_tys(param_env.and(ty)) else {
153-
return smallvec![ty];
154-
};
152+
let tys = tcx.list_significant_drop_tys(param_env.and(ty));
155153
debug!(?ty, "components");
156154
let mut out_tys = smallvec![];
157155
for ty in tys {
158-
if let ty::Coroutine(did, args) = ty.kind()
159-
&& let Some(witness) = tcx.mir_coroutine_witnesses(did)
160-
{
161-
for field in &witness.field_tys {
162-
out_tys.extend(extract_component_raw(
163-
tcx,
164-
param_env,
165-
ty::EarlyBinder::bind(field.ty).instantiate(tcx, args),
166-
));
167-
}
168-
} else {
169-
out_tys.push(ty);
170-
}
156+
out_tys.push(ty);
171157
}
172158
out_tys
173159
}

compiler/rustc_ty_utils/src/needs_drop.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,19 @@ fn adt_significant_drop_tys(
426426
fn list_significant_drop_tys<'tcx>(
427427
tcx: TyCtxt<'tcx>,
428428
ty: ty::ParamEnvAnd<'tcx, Ty<'tcx>>,
429-
) -> Result<&'tcx ty::List<Ty<'tcx>>, AlwaysRequiresDrop> {
430-
drop_tys_helper(tcx, ty.value, ty.param_env, adt_consider_insignificant_dtor(tcx), true, true)
431-
.collect::<Result<Vec<_>, _>>()
432-
.map(|components| tcx.mk_type_list(&components))
429+
) -> &'tcx ty::List<Ty<'tcx>> {
430+
tcx.mk_type_list(
431+
&drop_tys_helper(
432+
tcx,
433+
ty.value,
434+
ty.param_env,
435+
adt_consider_insignificant_dtor(tcx),
436+
true,
437+
true,
438+
)
439+
.filter_map(|res| res.ok())
440+
.collect::<Vec<_>>(),
441+
)
433442
}
434443

435444
pub(crate) fn provide(providers: &mut Providers) {

0 commit comments

Comments
 (0)