Rustup to rustc 1.17.0-nightly (7846dbe0c
2017-03-26)
7846dbe0c
2017-03-26)This commit is contained in:
parent
6706d8fdec
commit
065e9593b4
2 changed files with 8 additions and 18 deletions
|
@ -342,7 +342,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
||||||
Ok(Value::ByValPair(PrimVal::Ptr(ptr), PrimVal::from_u128(s.len() as u128)))
|
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::middle::const_val::ConstVal::*;
|
||||||
use rustc_const_math::ConstFloat;
|
use rustc_const_math::ConstFloat;
|
||||||
|
|
||||||
|
@ -364,7 +364,8 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
||||||
|
|
||||||
Struct(_) => unimplemented!(),
|
Struct(_) => unimplemented!(),
|
||||||
Tuple(_) => unimplemented!(),
|
Tuple(_) => unimplemented!(),
|
||||||
Function(_, _) => unimplemented!(),
|
// function items are zero sized and thus have no readable value
|
||||||
|
Function(..) => PrimVal::Undef,
|
||||||
Array(_) => unimplemented!(),
|
Array(_) => unimplemented!(),
|
||||||
Repeat(_, _) => unimplemented!(),
|
Repeat(_, _) => unimplemented!(),
|
||||||
};
|
};
|
||||||
|
@ -995,20 +996,15 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
||||||
match *op {
|
match *op {
|
||||||
Consume(ref lvalue) => self.eval_and_read_lvalue(lvalue),
|
Consume(ref lvalue) => self.eval_and_read_lvalue(lvalue),
|
||||||
|
|
||||||
Constant(mir::Constant { ref literal, ty, .. }) => {
|
Constant(mir::Constant { ref literal, .. }) => {
|
||||||
use rustc::mir::Literal;
|
use rustc::mir::Literal;
|
||||||
let value = match *literal {
|
let value = match *literal {
|
||||||
Literal::Value { ref value } => self.const_to_value(value)?,
|
Literal::Value { ref value } => self.const_to_value(value)?,
|
||||||
|
|
||||||
Literal::Item { def_id, substs } => {
|
Literal::Item { def_id, substs } => {
|
||||||
if let ty::TyFnDef(..) = ty.sty {
|
let instance = self.resolve_associated_const(def_id, substs);
|
||||||
// function items are zero sized
|
let cid = GlobalId { instance, promoted: None };
|
||||||
Value::ByRef(self.memory.allocate(0, 0)?)
|
self.globals.get(&cid).expect("static/const not cached").value
|
||||||
} 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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Literal::Promoted { index } => {
|
Literal::Promoted { index } => {
|
||||||
|
|
|
@ -195,13 +195,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for ConstantExtractor<'a, 'b, 'tcx> {
|
||||||
// already computed by rustc
|
// already computed by rustc
|
||||||
mir::Literal::Value { .. } => {}
|
mir::Literal::Value { .. } => {}
|
||||||
mir::Literal::Item { def_id, substs } => {
|
mir::Literal::Item { def_id, substs } => {
|
||||||
if let ty::TyFnDef(..) = constant.ty.sty {
|
self.global_item(def_id, substs, constant.span, true);
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
mir::Literal::Promoted { index } => {
|
mir::Literal::Promoted { index } => {
|
||||||
let cid = GlobalId {
|
let cid = GlobalId {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue