diff options
| author | bjorn3 <bjorn3@users.noreply.github.com> | 2018-12-02 13:57:41 +0100 |
|---|---|---|
| committer | bjorn3 <bjorn3@users.noreply.github.com> | 2019-03-29 17:17:11 +0100 |
| commit | a0c2ca1b56e64f4a5658ae0371da44e7af7cd58f (patch) | |
| tree | 01abb1b622eeeeaa5f61ba0c152d96b01e48ea57 /src/librustc_codegen_ssa | |
| parent | 2b688a959def6d3441d3e4854fde557de0913e36 (diff) | |
| download | rust-a0c2ca1b56e64f4a5658ae0371da44e7af7cd58f.tar.gz rust-a0c2ca1b56e64f4a5658ae0371da44e7af7cd58f.zip | |
`eval_mir_constant` doesn't need a builder param
Diffstat (limited to 'src/librustc_codegen_ssa')
| -rw-r--r-- | src/librustc_codegen_ssa/mir/block.rs | 2 | ||||
| -rw-r--r-- | src/librustc_codegen_ssa/mir/constant.rs | 7 | ||||
| -rw-r--r-- | src/librustc_codegen_ssa/mir/operand.rs | 2 |
3 files changed, 5 insertions, 6 deletions
diff --git a/src/librustc_codegen_ssa/mir/block.rs b/src/librustc_codegen_ssa/mir/block.rs index 4774f8fe5a3..494355efeaa 100644 --- a/src/librustc_codegen_ssa/mir/block.rs +++ b/src/librustc_codegen_ssa/mir/block.rs @@ -657,7 +657,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { span_bug!(span, "shuffle indices must be constant"); } mir::Operand::Constant(ref constant) => { - let c = self.eval_mir_constant(&bx, constant); + let c = self.eval_mir_constant(constant); let (llval, ty) = self.simd_shuffle_indices( &bx, constant.span, diff --git a/src/librustc_codegen_ssa/mir/constant.rs b/src/librustc_codegen_ssa/mir/constant.rs index a1d44b228a5..3f8dc420cf4 100644 --- a/src/librustc_codegen_ssa/mir/constant.rs +++ b/src/librustc_codegen_ssa/mir/constant.rs @@ -3,7 +3,7 @@ use rustc_mir::const_eval::const_field; use rustc::mir; use rustc_data_structures::indexed_vec::Idx; use rustc::ty::{self, Ty}; -use rustc::ty::layout; +use rustc::ty::layout::{self, HasTyCtxt}; use syntax::source_map::Span; use crate::traits::*; @@ -12,20 +12,19 @@ use super::FunctionCx; impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { pub fn eval_mir_constant( &mut self, - bx: &Bx, constant: &mir::Constant<'tcx>, ) -> Result<ty::Const<'tcx>, ErrorHandled> { 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, + self.cx.tcx(), ty::ParamEnv::reveal_all(), def_id, substs, ).unwrap(); let cid = mir::interpret::GlobalId { instance, promoted: None, }; - bx.tcx().const_eval(ty::ParamEnv::reveal_all().and(cid)) + self.cx.tcx().const_eval(ty::ParamEnv::reveal_all().and(cid)) }, _ => Ok(*self.monomorphize(&constant.literal)), } diff --git a/src/librustc_codegen_ssa/mir/operand.rs b/src/librustc_codegen_ssa/mir/operand.rs index e17a6e7b03f..289129e8e62 100644 --- a/src/librustc_codegen_ssa/mir/operand.rs +++ b/src/librustc_codegen_ssa/mir/operand.rs @@ -460,7 +460,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { mir::Operand::Constant(ref constant) => { let ty = self.monomorphize(&constant.ty); - self.eval_mir_constant(bx, constant) + self.eval_mir_constant(constant) .and_then(|c| OperandRef::from_const(bx, c)) .unwrap_or_else(|err| { match err { |
