From 122e91e3307ac2e36565f52623074badae09e02c Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Fri, 3 Sep 2021 09:25:27 +0000 Subject: [PATCH] do not require lang item --- .../src/transform/check_consts/qualifs.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs b/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs index ea8f0a29181..c6f786ca538 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs @@ -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(