about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2022-09-25 14:44:51 +0200
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2022-09-25 14:44:51 +0200
commit241eae76e209b578b75b916e0e9a7d6ea24deb43 (patch)
tree6d36408bf13be8817eb837564bdee5147fe11e26
parent5ed4377677f071489ad24860ac2c6c3fac324921 (diff)
downloadrust-241eae76e209b578b75b916e0e9a7d6ea24deb43.tar.gz
rust-241eae76e209b578b75b916e0e9a7d6ea24deb43.zip
Monomorphize ConstantKind::Unevaluated in mir_operand_get_const_val
-rw-r--r--src/constant.rs11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/constant.rs b/src/constant.rs
index d1610b4005f..da4a96c4acc 100644
--- a/src/constant.rs
+++ b/src/constant.rs
@@ -459,14 +459,13 @@ pub(crate) fn mir_operand_get_const_val<'tcx>(
     operand: &Operand<'tcx>,
 ) -> Option<ConstValue<'tcx>> {
     match operand {
-        Operand::Constant(const_) => match const_.literal {
-            ConstantKind::Ty(const_) => fx
-                .monomorphize(const_)
-                .eval_for_mir(fx.tcx, ParamEnv::reveal_all())
-                .try_to_value(fx.tcx),
+        Operand::Constant(const_) => match fx.monomorphize(const_.literal) {
+            ConstantKind::Ty(const_) => Some(
+                const_.eval_for_mir(fx.tcx, ParamEnv::reveal_all()).try_to_value(fx.tcx).unwrap(),
+            ),
             ConstantKind::Val(val, _) => Some(val),
             ConstantKind::Unevaluated(uv, _) => {
-                fx.tcx.const_eval_resolve(ParamEnv::reveal_all(), uv, None).ok()
+                Some(fx.tcx.const_eval_resolve(ParamEnv::reveal_all(), uv, None).unwrap())
             }
         },
         // FIXME(rust-lang/rust#85105): Casts like `IMM8 as u32` result in the const being stored