diff --git a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs index 669838308a558..cc8b10bd07d78 100644 --- a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs +++ b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs @@ -132,8 +132,8 @@ pub(super) fn op_to_const<'tcx>( // functionality.) _ => false, }; - let immediate = if force_as_immediate { - Right(ecx.read_immediate(op).expect("normalization works on validated constants")) + let immediate = if force_as_immediate && let Ok(imm) = ecx.read_immediate(op) { + Right(imm) } else { op.as_mplace_or_imm() };