Rollup merge of #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.
This commit is contained in:
commit
d61a4735f7
3 changed files with 6 additions and 17 deletions
|
@ -1124,10 +1124,8 @@ pub struct Destructor {
|
|||
// FIXME: consider combining this definition with regular `Destructor`
|
||||
#[derive(Copy, Clone, Debug, HashStable, Encodable, Decodable)]
|
||||
pub struct AsyncDestructor {
|
||||
/// The `DefId` of the async destructor future constructor
|
||||
pub ctor: DefId,
|
||||
/// The `DefId` of the async destructor future type
|
||||
pub future: DefId,
|
||||
/// The `DefId` of the `impl AsyncDrop`
|
||||
pub impl_did: LocalDefId,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, HashStable, TyEncodable, TyDecodable)]
|
||||
|
|
|
@ -154,7 +154,7 @@ pub fn ty_dtor_span<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option<Span> {
|
|||
let dtor = if let Some(dtor) = tcx.adt_destructor(did) {
|
||||
dtor.did
|
||||
} else if let Some(dtor) = tcx.adt_async_destructor(did) {
|
||||
dtor.future
|
||||
return Some(tcx.source_span(dtor.impl_did));
|
||||
} else {
|
||||
return Some(try_local_did_span(did));
|
||||
};
|
||||
|
|
|
@ -455,26 +455,17 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
continue;
|
||||
}
|
||||
|
||||
let [future, ctor] = self.associated_item_def_ids(impl_did) else {
|
||||
self.dcx().span_delayed_bug(
|
||||
self.def_span(impl_did),
|
||||
"AsyncDrop impl without async_drop function or Dropper type",
|
||||
);
|
||||
continue;
|
||||
};
|
||||
|
||||
if let Some((_, _, old_impl_did)) = dtor_candidate {
|
||||
if let Some(old_impl_did) = dtor_candidate {
|
||||
self.dcx()
|
||||
.struct_span_err(self.def_span(impl_did), "multiple async drop impls found")
|
||||
.with_span_note(self.def_span(old_impl_did), "other impl here")
|
||||
.delay_as_bug();
|
||||
}
|
||||
|
||||
dtor_candidate = Some((*future, *ctor, impl_did));
|
||||
dtor_candidate = Some(impl_did);
|
||||
}
|
||||
|
||||
let (future, ctor, _) = dtor_candidate?;
|
||||
Some(ty::AsyncDestructor { future, ctor })
|
||||
Some(ty::AsyncDestructor { impl_did: dtor_candidate? })
|
||||
}
|
||||
|
||||
/// Returns async drop glue morphology for a definition. To get async drop
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue