diff options
| author | Lukas Markeffsky <@> | 2022-11-11 10:01:06 +0100 |
|---|---|---|
| committer | Lukas Markeffsky <@> | 2022-11-19 16:47:42 +0100 |
| commit | 60f352fd7d1b3443a07bbfefb955a4e836749ee6 (patch) | |
| tree | 7c4758e41efc73db41a155581d13b46b3745faaf | |
| parent | 8a6053618f99852d31b46144043e881f6556ff1c (diff) | |
| download | rust-60f352fd7d1b3443a07bbfefb955a4e836749ee6.tar.gz rust-60f352fd7d1b3443a07bbfefb955a4e836749ee6.zip | |
replace potential ICE with graceful error (`no_core` only)
| -rw-r--r-- | compiler/rustc_const_eval/src/const_eval/machine.rs | 5 |
1 files 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(), |
