Skip to content

Commit 86104b4

Browse files
committed
eval_mir_constant doesn't need a builder param
1 parent c324b4e commit 86104b4

File tree

3 files changed

+23
-26
lines changed

3 files changed

+23
-26
lines changed

src/librustc_codegen_ssa/mir/block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
640640
span_bug!(span, "shuffle indices must be constant");
641641
}
642642
mir::Operand::Constant(ref constant) => {
643-
let c = self.eval_mir_constant(&bx, constant);
643+
let c = self.eval_mir_constant(constant);
644644
let (llval, ty) = self.simd_shuffle_indices(
645645
&bx,
646646
constant.span,

src/librustc_codegen_ssa/mir/constant.rs

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,38 @@ use rustc_mir::const_eval::const_field;
33
use rustc::mir;
44
use rustc_data_structures::indexed_vec::Idx;
55
use rustc::mir::interpret::GlobalId;
6-
use rustc::ty::{self, Ty};
7-
use rustc::ty::layout;
6+
use rustc::ty::{self, Ty, TyCtxt};
7+
use rustc::ty::layout::{self, HasTyCtxt};
88
use syntax::source_map::Span;
99
use crate::traits::*;
1010

1111
use super::FunctionCx;
1212

13-
impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
14-
fn fully_evaluate(
15-
&mut self,
16-
bx: &Bx,
17-
constant: &'tcx ty::LazyConst<'tcx>,
18-
) -> Result<ty::Const<'tcx>, ErrorHandled> {
19-
match *constant {
20-
ty::LazyConst::Unevaluated(def_id, ref substs) => {
21-
let tcx = bx.tcx();
22-
let param_env = ty::ParamEnv::reveal_all();
23-
let instance = ty::Instance::resolve(tcx, param_env, def_id, substs).unwrap();
24-
let cid = GlobalId {
25-
instance,
26-
promoted: None,
27-
};
28-
tcx.const_eval(param_env.and(cid))
29-
},
30-
ty::LazyConst::Evaluated(constant) => Ok(constant),
31-
}
13+
fn fully_evaluate<'a, 'tcx: 'a>(
14+
tcx: TyCtxt<'a, 'tcx, 'tcx>,
15+
constant: &'tcx ty::LazyConst<'tcx>,
16+
) -> Result<ty::Const<'tcx>, ErrorHandled> {
17+
match *constant {
18+
ty::LazyConst::Unevaluated(def_id, ref substs) => {
19+
let param_env = ty::ParamEnv::reveal_all();
20+
let instance = ty::Instance::resolve(tcx, param_env, def_id, substs).unwrap();
21+
let cid = GlobalId {
22+
instance,
23+
promoted: None,
24+
};
25+
tcx.const_eval(param_env.and(cid))
26+
},
27+
ty::LazyConst::Evaluated(constant) => Ok(constant),
3228
}
29+
}
3330

31+
impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
3432
pub fn eval_mir_constant(
35-
&mut self,
36-
bx: &Bx,
33+
&self,
3734
constant: &mir::Constant<'tcx>,
3835
) -> Result<ty::Const<'tcx>, ErrorHandled> {
3936
let c = self.monomorphize(&constant.literal);
40-
self.fully_evaluate(bx, c)
37+
fully_evaluate(self.cx.tcx(), c)
4138
}
4239

4340
/// process constant containing SIMD shuffle indices

src/librustc_codegen_ssa/mir/operand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
457457

458458
mir::Operand::Constant(ref constant) => {
459459
let ty = self.monomorphize(&constant.ty);
460-
self.eval_mir_constant(bx, constant)
460+
self.eval_mir_constant(constant)
461461
.and_then(|c| OperandRef::from_const(bx, c))
462462
.unwrap_or_else(|err| {
463463
match err {

0 commit comments

Comments
 (0)