diff options
| author | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2019-03-14 10:19:31 +0100 |
|---|---|---|
| committer | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2019-03-16 21:04:10 +0100 |
| commit | 5cd28066214a4a255bac6655c20bf05cb95730fd (patch) | |
| tree | a05eb07e841948afde869d2008b0aab68f55d24a /src/librustc_codegen_ssa | |
| parent | 2c8bbf50db0ef90a33f986ba8fc2e1fe129197ff (diff) | |
| download | rust-5cd28066214a4a255bac6655c20bf05cb95730fd.tar.gz rust-5cd28066214a4a255bac6655c20bf05cb95730fd.zip | |
Revert the `LazyConst` PR
Diffstat (limited to 'src/librustc_codegen_ssa')
| -rw-r--r-- | src/librustc_codegen_ssa/mir/constant.rs | 31 | ||||
| -rw-r--r-- | src/librustc_codegen_ssa/mir/operand.rs | 1 |
2 files changed, 12 insertions, 20 deletions
diff --git a/src/librustc_codegen_ssa/mir/constant.rs b/src/librustc_codegen_ssa/mir/constant.rs index 2bb68dc687c..a1d44b228a5 100644 --- a/src/librustc_codegen_ssa/mir/constant.rs +++ b/src/librustc_codegen_ssa/mir/constant.rs @@ -2,7 +2,6 @@ use rustc::mir::interpret::ErrorHandled; use rustc_mir::const_eval::const_field; use rustc::mir; use rustc_data_structures::indexed_vec::Idx; -use rustc::mir::interpret::GlobalId; use rustc::ty::{self, Ty}; use rustc::ty::layout; use syntax::source_map::Span; @@ -11,35 +10,27 @@ use crate::traits::*; use super::FunctionCx; impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { - fn fully_evaluate( + pub fn eval_mir_constant( &mut self, bx: &Bx, - constant: &'tcx ty::LazyConst<'tcx>, + constant: &mir::Constant<'tcx>, ) -> Result<ty::Const<'tcx>, ErrorHandled> { - match *constant { - ty::LazyConst::Unevaluated(def_id, ref substs) => { - let tcx = bx.tcx(); - let param_env = ty::ParamEnv::reveal_all(); - let instance = ty::Instance::resolve(tcx, param_env, def_id, substs).unwrap(); - let cid = GlobalId { + match constant.literal.val { + mir::interpret::ConstValue::Unevaluated(def_id, ref substs) => { + let substs = self.monomorphize(substs); + let instance = ty::Instance::resolve( + bx.tcx(), ty::ParamEnv::reveal_all(), def_id, substs, + ).unwrap(); + let cid = mir::interpret::GlobalId { instance, promoted: None, }; - tcx.const_eval(param_env.and(cid)) + bx.tcx().const_eval(ty::ParamEnv::reveal_all().and(cid)) }, - ty::LazyConst::Evaluated(constant) => Ok(constant), + _ => Ok(*self.monomorphize(&constant.literal)), } } - pub fn eval_mir_constant( - &mut self, - bx: &Bx, - constant: &mir::Constant<'tcx>, - ) -> Result<ty::Const<'tcx>, ErrorHandled> { - let c = self.monomorphize(&constant.literal); - self.fully_evaluate(bx, c) - } - /// process constant containing SIMD shuffle indices pub fn simd_shuffle_indices( &mut self, diff --git a/src/librustc_codegen_ssa/mir/operand.rs b/src/librustc_codegen_ssa/mir/operand.rs index 55a1eb016e0..e17a6e7b03f 100644 --- a/src/librustc_codegen_ssa/mir/operand.rs +++ b/src/librustc_codegen_ssa/mir/operand.rs @@ -76,6 +76,7 @@ impl<'a, 'tcx: 'a, V: CodegenObject> OperandRef<'tcx, V> { } let val = match val.val { + ConstValue::Unevaluated(..) => bug!("unevaluated constant in `OperandRef::from_const`"), ConstValue::Param(_) => bug!("encountered a ConstValue::Param in codegen"), ConstValue::Infer(_) => bug!("encountered a ConstValue::Infer in codegen"), ConstValue::Scalar(x) => { |
