1
Fork 0

Rustup to rustc 1.17.0-nightly (7846dbe0c 2017-03-26)

This commit is contained in:
Oliver Schneider 2017-03-27 10:13:21 +02:00
parent 6706d8fdec
commit 065e9593b4
2 changed files with 8 additions and 18 deletions

View file

@ -342,7 +342,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
Ok(Value::ByValPair(PrimVal::Ptr(ptr), PrimVal::from_u128(s.len() as u128)))
}
pub(super) fn const_to_value(&mut self, const_val: &ConstVal) -> EvalResult<'tcx, Value> {
pub(super) fn const_to_value(&mut self, const_val: &ConstVal<'tcx>) -> EvalResult<'tcx, Value> {
use rustc::middle::const_val::ConstVal::*;
use rustc_const_math::ConstFloat;
@ -364,7 +364,8 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
Struct(_) => unimplemented!(),
Tuple(_) => unimplemented!(),
Function(_, _) => unimplemented!(),
// function items are zero sized and thus have no readable value
Function(..) => PrimVal::Undef,
Array(_) => unimplemented!(),
Repeat(_, _) => unimplemented!(),
};
@ -995,20 +996,15 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
match *op {
Consume(ref lvalue) => self.eval_and_read_lvalue(lvalue),
Constant(mir::Constant { ref literal, ty, .. }) => {
Constant(mir::Constant { ref literal, .. }) => {
use rustc::mir::Literal;
let value = match *literal {
Literal::Value { ref value } => self.const_to_value(value)?,
Literal::Item { def_id, substs } => {
if let ty::TyFnDef(..) = ty.sty {
// function items are zero sized
Value::ByRef(self.memory.allocate(0, 0)?)
} else {
let instance = self.resolve_associated_const(def_id, substs);
let cid = GlobalId { instance, promoted: None };
self.globals.get(&cid).expect("static/const not cached").value
}
let instance = self.resolve_associated_const(def_id, substs);
let cid = GlobalId { instance, promoted: None };
self.globals.get(&cid).expect("static/const not cached").value
}
Literal::Promoted { index } => {

View file

@ -195,13 +195,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for ConstantExtractor<'a, 'b, 'tcx> {
// already computed by rustc
mir::Literal::Value { .. } => {}
mir::Literal::Item { def_id, substs } => {
if let ty::TyFnDef(..) = constant.ty.sty {
// No need to do anything here,
// because the type is the actual function, not the signature of the function.
// Thus we can simply create a zero sized allocation in `evaluate_operand`
} else {
self.global_item(def_id, substs, constant.span, true);
}
self.global_item(def_id, substs, constant.span, true);
},
mir::Literal::Promoted { index } => {
let cid = GlobalId {