]> git.lizzy.rs Git - rust.git/commitdiff
Rustup to `rustc 1.17.0-nightly (7846dbe0c 2017-03-26)`
authorOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Mon, 27 Mar 2017 08:13:21 +0000 (10:13 +0200)
committerOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Mon, 27 Mar 2017 08:13:21 +0000 (10:13 +0200)
src/eval_context.rs
src/step.rs

index 5cd790797b471a5c9eec33feb80e5859b44d8e35..bbee49bae84c85a358893b67d2fe19a7a44967a1 100644 (file)
@@ -342,7 +342,7 @@ pub(crate) fn str_to_value(&mut self, s: &str) -> EvalResult<'tcx, Value> {
         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 @@ pub(super) fn const_to_value(&mut self, const_val: &ConstVal) -> EvalResult<'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 @@ pub(super) fn eval_operand(&mut self, op: &mir::Operand<'tcx>) -> EvalResult<'tc
         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 } => {
index 8a0cbc4a8f1c9d08bbd60602d8a558368060497f..79e940bee533ba0be7f83f1e919ce921574d40c8 100644 (file)
@@ -195,13 +195,7 @@ fn visit_constant(&mut self, constant: &mir::Constant<'tcx>, location: mir::Loca
             // 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 {