-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
//! Propagates constants for early reporting of statically known
//! assertion failures
use interpret::{self, EvalContext, ScalarMaybeUndef, Immediate, OpTy, MemoryKind};
use const_eval::{
- CompileTimeInterpreter, const_to_op, error_to_const_error, eval_promoted, mk_borrowck_eval_cx
+ CompileTimeInterpreter, error_to_const_error, eval_promoted, mk_eval_cx,
+ lazy_const_to_op,
};
use transform::{MirPass, MirSource};
source: MirSource,
) -> ConstPropagator<'a, 'mir, 'tcx> {
let param_env = tcx.param_env(source.def_id);
- let substs = Substs::identity_for_item(tcx, source.def_id);
- let instance = Instance::new(source.def_id, substs);
- let ecx = mk_borrowck_eval_cx(tcx, instance, mir, DUMMY_SP).unwrap();
+ let ecx = mk_eval_cx(tcx, tcx.def_span(source.def_id), param_env);
ConstPropagator {
ecx,
mir,
source_info: SourceInfo,
) -> Option<Const<'tcx>> {
self.ecx.tcx.span = source_info.span;
- match const_to_op(&self.ecx, c.literal) {
+ match lazy_const_to_op(&self.ecx, *c.literal, c.ty) {
Ok(op) => {
Some((op, c.span))
},