diff options
| author | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2022-09-25 14:44:51 +0200 |
|---|---|---|
| committer | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2022-09-25 14:44:51 +0200 |
| commit | 241eae76e209b578b75b916e0e9a7d6ea24deb43 (patch) | |
| tree | 6d36408bf13be8817eb837564bdee5147fe11e26 | |
| parent | 5ed4377677f071489ad24860ac2c6c3fac324921 (diff) | |
| download | rust-241eae76e209b578b75b916e0e9a7d6ea24deb43.tar.gz rust-241eae76e209b578b75b916e0e9a7d6ea24deb43.zip | |
Monomorphize ConstantKind::Unevaluated in mir_operand_get_const_val
| -rw-r--r-- | src/constant.rs | 11 |
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 |
