Fetch the destructor constness lazily

This commit is contained in:
Oli Scherer 2025-04-01 09:28:46 +00:00
parent ca32447c0c
commit 6697f02761
4 changed files with 6 additions and 8 deletions

View file

@ -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.