From 60f352fd7d1b3443a07bbfefb955a4e836749ee6 Mon Sep 17 00:00:00 2001 From: Lukas Markeffsky <@> Date: Fri, 11 Nov 2022 10:01:06 +0100 Subject: [PATCH] replace potential ICE with graceful error (`no_core` only) --- compiler/rustc_const_eval/src/const_eval/machine.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_const_eval/src/const_eval/machine.rs b/compiler/rustc_const_eval/src/const_eval/machine.rs index 6cf8a581d71..93afbbd27a4 100644 --- a/compiler/rustc_const_eval/src/const_eval/machine.rs +++ b/compiler/rustc_const_eval/src/const_eval/machine.rs @@ -1,4 +1,5 @@ use rustc_hir::def::DefKind; +use rustc_hir::LangItem; use rustc_middle::mir; use rustc_middle::mir::interpret::PointerArithmetic; use rustc_middle::ty::layout::LayoutOf; @@ -178,9 +179,7 @@ impl<'mir, 'tcx: 'mir> CompileTimeEvalContext<'mir, 'tcx> { return Err(ConstEvalErrKind::Panic { msg, file, line, col }.into()); } else if Some(def_id) == self.tcx.lang_items().panic_fmt() { // For panic_fmt, call const_panic_fmt instead. - let Some(const_def_id) = self.tcx.lang_items().const_panic_fmt() else { - bug!("`const_panic_fmt` must be defined to call `panic_fmt` in const eval") - }; + let const_def_id = self.tcx.require_lang_item(LangItem::ConstPanicFmt, None); let new_instance = ty::Instance::resolve( *self.tcx, ty::ParamEnv::reveal_all(),