mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-06 04:08:40 +00:00
Fetch the destructor constness lazily
This commit is contained in:
parent
ca32447c0c
commit
6697f02761
@ -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.
|
||||
|
@ -263,7 +263,7 @@ fn evaluate_host_effect_for_destruct_goal<'tcx>(
|
||||
.all_fields()
|
||||
.map(|field| ty::TraitRef::new(tcx, destruct_def_id, [field.ty(tcx, args)]))
|
||||
.collect();
|
||||
match adt_def.destructor(tcx).map(|dtor| dtor.constness) {
|
||||
match adt_def.destructor(tcx).map(|dtor| tcx.constness(dtor.did)) {
|
||||
// `Drop` impl exists, but it's not const. Type cannot be `~const Destruct`.
|
||||
Some(hir::Constness::NotConst) => return Err(EvaluationFailure::NoSolution),
|
||||
// `Drop` impl exists, and it's const. Require `Ty: ~const Drop` to hold.
|
||||
|
Loading…
Reference in New Issue
Block a user