Skip to content

Commit 91bdd1f

Browse files
authored
Unrolled build for rust-lang#139348
Rollup merge of rust-lang#139348 - meithecatte:async-destructor-minify, r=petrochenkov AsyncDestructor: replace fields with impl_did The future and ctor fields aren't actually used, and the way they are extracted is obviously wrong – swapping the order of the items in the source code will give wrong results. Instead, store just the LocalDefId of the impl, which is enough for the only use of this data.
2 parents 17ffbc8 + a2618e1 commit 91bdd1f

File tree

3 files changed

+6
-17
lines changed

3 files changed

+6
-17
lines changed

compiler/rustc_middle/src/ty/mod.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1147,10 +1147,8 @@ pub struct Destructor {
11471147
// FIXME: consider combining this definition with regular `Destructor`
11481148
#[derive(Copy, Clone, Debug, HashStable, Encodable, Decodable)]
11491149
pub struct AsyncDestructor {
1150-
/// The `DefId` of the async destructor future constructor
1151-
pub ctor: DefId,
1152-
/// The `DefId` of the async destructor future type
1153-
pub future: DefId,
1150+
/// The `DefId` of the `impl AsyncDrop`
1151+
pub impl_did: LocalDefId,
11541152
}
11551153

11561154
#[derive(Clone, Copy, PartialEq, Eq, HashStable, TyEncodable, TyDecodable)]

compiler/rustc_middle/src/ty/significant_drop_order.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ pub fn ty_dtor_span<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option<Span> {
154154
let dtor = if let Some(dtor) = tcx.adt_destructor(did) {
155155
dtor.did
156156
} else if let Some(dtor) = tcx.adt_async_destructor(did) {
157-
dtor.future
157+
return Some(tcx.source_span(dtor.impl_did));
158158
} else {
159159
return Some(try_local_did_span(did));
160160
};

compiler/rustc_middle/src/ty/util.rs

+3-12
Original file line numberDiff line numberDiff line change
@@ -455,26 +455,17 @@ impl<'tcx> TyCtxt<'tcx> {
455455
continue;
456456
}
457457

458-
let [future, ctor] = self.associated_item_def_ids(impl_did) else {
459-
self.dcx().span_delayed_bug(
460-
self.def_span(impl_did),
461-
"AsyncDrop impl without async_drop function or Dropper type",
462-
);
463-
continue;
464-
};
465-
466-
if let Some((_, _, old_impl_did)) = dtor_candidate {
458+
if let Some(old_impl_did) = dtor_candidate {
467459
self.dcx()
468460
.struct_span_err(self.def_span(impl_did), "multiple async drop impls found")
469461
.with_span_note(self.def_span(old_impl_did), "other impl here")
470462
.delay_as_bug();
471463
}
472464

473-
dtor_candidate = Some((*future, *ctor, impl_did));
465+
dtor_candidate = Some(impl_did);
474466
}
475467

476-
let (future, ctor, _) = dtor_candidate?;
477-
Some(ty::AsyncDestructor { future, ctor })
468+
Some(ty::AsyncDestructor { impl_did: dtor_candidate? })
478469
}
479470

480471
/// Returns async drop glue morphology for a definition. To get async drop

0 commit comments

Comments
 (0)