do not require lang item

This commit is contained in:
Deadbeef 2021-09-03 09:25:27 +00:00
parent 82117289f2
commit 122e91e330
No known key found for this signature in database
GPG Key ID: 027DF9338862ADDD

View File

@ -112,8 +112,15 @@ impl Qualif for NeedsNonConstDrop {
}
fn in_any_value_of_ty(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>) -> bool {
let drop_trait = if let Some(did) = cx.tcx.lang_items().drop_trait() {
did
} else {
// there is no way to define a type that needs non-const drop
// without having the lang item present.
return false;
};
let trait_ref = ty::TraitRef {
def_id: cx.tcx.require_lang_item(hir::LangItem::Drop, None),
def_id: drop_trait,
substs: cx.tcx.mk_substs_trait(ty, &[]),
};
let obligation = Obligation::new(