Fetch the destructor constness lazily
This commit is contained in:
parent
ca32447c0c
commit
6697f02761
4 changed files with 6 additions and 8 deletions
|
@ -236,7 +236,7 @@ impl<'tcx> rustc_type_ir::inherent::AdtDef<TyCtxt<'tcx>> for AdtDef<'tcx> {
|
|||
}
|
||||
|
||||
fn destructor(self, tcx: TyCtxt<'tcx>) -> Option<AdtDestructorKind> {
|
||||
Some(match self.destructor(tcx)?.constness {
|
||||
Some(match tcx.constness(self.destructor(tcx)?.did) {
|
||||
hir::Constness::Const => AdtDestructorKind::Const,
|
||||
hir::Constness::NotConst => AdtDestructorKind::NotConst,
|
||||
})
|
||||
|
|
|
@ -1119,8 +1119,6 @@ pub struct PseudoCanonicalInput<'tcx, T> {
|
|||
pub struct Destructor {
|
||||
/// The `DefId` of the destructor method
|
||||
pub did: DefId,
|
||||
/// The constness of the destructor method
|
||||
pub constness: hir::Constness,
|
||||
}
|
||||
|
||||
// FIXME: consider combining this definition with regular `Destructor`
|
||||
|
|
|
@ -414,18 +414,18 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
continue;
|
||||
};
|
||||
|
||||
if let Some((old_item_id, _)) = dtor_candidate {
|
||||
if let Some(old_item_id) = dtor_candidate {
|
||||
self.dcx()
|
||||
.struct_span_err(self.def_span(item_id), "multiple drop impls found")
|
||||
.with_span_note(self.def_span(old_item_id), "other impl here")
|
||||
.delay_as_bug();
|
||||
}
|
||||
|
||||
dtor_candidate = Some((*item_id, self.impl_trait_header(impl_did).unwrap().constness));
|
||||
dtor_candidate = Some(*item_id);
|
||||
}
|
||||
|
||||
let (did, constness) = dtor_candidate?;
|
||||
Some(ty::Destructor { did, constness })
|
||||
let did = dtor_candidate?;
|
||||
Some(ty::Destructor { did })
|
||||
}
|
||||
|
||||
/// Calculate the async destructor of a given type.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue