Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/significant_drop_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
};
Expand Down
15 changes: 3 additions & 12 deletions compiler/rustc_middle/src/ty/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,26 +450,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
Expand Down
Loading