eval_mir_constant
doesn't need a builder param
This commit is contained in:
parent
2b688a959d
commit
a0c2ca1b56
3 changed files with 5 additions and 6 deletions
|
@ -657,7 +657,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
span_bug!(span, "shuffle indices must be constant");
|
span_bug!(span, "shuffle indices must be constant");
|
||||||
}
|
}
|
||||||
mir::Operand::Constant(ref 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(
|
let (llval, ty) = self.simd_shuffle_indices(
|
||||||
&bx,
|
&bx,
|
||||||
constant.span,
|
constant.span,
|
||||||
|
|
|
@ -3,7 +3,7 @@ use rustc_mir::const_eval::const_field;
|
||||||
use rustc::mir;
|
use rustc::mir;
|
||||||
use rustc_data_structures::indexed_vec::Idx;
|
use rustc_data_structures::indexed_vec::Idx;
|
||||||
use rustc::ty::{self, Ty};
|
use rustc::ty::{self, Ty};
|
||||||
use rustc::ty::layout;
|
use rustc::ty::layout::{self, HasTyCtxt};
|
||||||
use syntax::source_map::Span;
|
use syntax::source_map::Span;
|
||||||
use crate::traits::*;
|
use crate::traits::*;
|
||||||
|
|
||||||
|
@ -12,20 +12,19 @@ use super::FunctionCx;
|
||||||
impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
pub fn eval_mir_constant(
|
pub fn eval_mir_constant(
|
||||||
&mut self,
|
&mut self,
|
||||||
bx: &Bx,
|
|
||||||
constant: &mir::Constant<'tcx>,
|
constant: &mir::Constant<'tcx>,
|
||||||
) -> Result<ty::Const<'tcx>, ErrorHandled> {
|
) -> Result<ty::Const<'tcx>, ErrorHandled> {
|
||||||
match constant.literal.val {
|
match constant.literal.val {
|
||||||
mir::interpret::ConstValue::Unevaluated(def_id, ref substs) => {
|
mir::interpret::ConstValue::Unevaluated(def_id, ref substs) => {
|
||||||
let substs = self.monomorphize(substs);
|
let substs = self.monomorphize(substs);
|
||||||
let instance = ty::Instance::resolve(
|
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();
|
).unwrap();
|
||||||
let cid = mir::interpret::GlobalId {
|
let cid = mir::interpret::GlobalId {
|
||||||
instance,
|
instance,
|
||||||
promoted: None,
|
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)),
|
_ => Ok(*self.monomorphize(&constant.literal)),
|
||||||
}
|
}
|
||||||
|
|
|
@ -460,7 +460,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
|
|
||||||
mir::Operand::Constant(ref constant) => {
|
mir::Operand::Constant(ref constant) => {
|
||||||
let ty = self.monomorphize(&constant.ty);
|
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))
|
.and_then(|c| OperandRef::from_const(bx, c))
|
||||||
.unwrap_or_else(|err| {
|
.unwrap_or_else(|err| {
|
||||||
match err {
|
match err {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue