about summary refs log tree commit diff
path: root/src/librustc_codegen_ssa
diff options
context:
space:
mode:
authorBastian Kauschke <bastian_kauschke@hotmail.de>2020-03-22 11:53:13 +0100
committerBastian Kauschke <bastian_kauschke@hotmail.de>2020-03-22 11:53:13 +0100
commited4885359a42354fee8229760c845bf534266427 (patch)
tree5c00c8590e9560412c9a8baadbd0c30a725f0db8 /src/librustc_codegen_ssa
parent0c5c3bbdabc60bd7dd7491dfcf6befb8202d7521 (diff)
downloadrust-ed4885359a42354fee8229760c845bf534266427.tar.gz
rust-ed4885359a42354fee8229760c845bf534266427.zip
simplify eval_mir_constant
Diffstat (limited to 'src/librustc_codegen_ssa')
-rw-r--r--src/librustc_codegen_ssa/mir/constant.rs16
1 files changed, 3 insertions, 13 deletions
diff --git a/src/librustc_codegen_ssa/mir/constant.rs b/src/librustc_codegen_ssa/mir/constant.rs
index 0fcd11d8100..74a9646a0c0 100644
--- a/src/librustc_codegen_ssa/mir/constant.rs
+++ b/src/librustc_codegen_ssa/mir/constant.rs
@@ -40,17 +40,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
         &mut self,
         constant: &mir::Constant<'tcx>,
     ) -> Result<ConstValue<'tcx>, ErrorHandled> {
-        let const_ = match constant.literal.val {
-            ty::ConstKind::Unevaluated(def_id, substs, promoted) => {
-                let substs = self.monomorphize(&substs);
-                ty::ConstKind::Unevaluated(def_id, substs, promoted)
-            }
-            ty::ConstKind::Value(value) => ty::ConstKind::Value(value),
-            ty::ConstKind::Param(_) => self.monomorphize(&constant.literal).val,
-            _ => span_bug!(constant.span, "encountered bad Const in codegen: {:?}", constant),
-        };
-
-        match const_ {
+        match self.monomorphize(&constant.literal).val {
             ty::ConstKind::Unevaluated(def_id, substs, promoted) => self
                 .cx
                 .tcx()
@@ -65,10 +55,10 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
                     err
                 }),
             ty::ConstKind::Value(value) => Ok(value),
-            _ => span_bug!(
+            err => span_bug!(
                 constant.span,
                 "encountered bad ConstKind after monomorphizing: {:?}",
-                const_
+                err
             ),
         }
     }