Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
eval_mir_constant doesn't need a builder param
  • Loading branch information
bjorn3 committed Mar 29, 2019
commit a0c2ca1b56e64f4a5658ae0371da44e7af7cd58f
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/mir/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 3 additions & 4 deletions src/librustc_codegen_ssa/mir/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;

Expand All @@ -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)),
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/mir/operand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down