]> git.lizzy.rs Git - rust.git/commitdiff
make sure globals that yield function pointers aren't treated like functions
authorOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Thu, 9 Jun 2016 09:27:02 +0000 (11:27 +0200)
committerOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Thu, 9 Jun 2016 09:27:02 +0000 (11:27 +0200)
src/interpreter/mod.rs
src/interpreter/stepper.rs

index 15fa4cdd3b842c48a6b4ba945285f5ec38b747dc..6c0d58f1c47e77dc3b3c660fbe236458655d3102 100644 (file)
@@ -1189,7 +1189,7 @@ fn eval_operand(&mut self, op: &mir::Operand<'tcx>) -> EvalResult<Pointer> {
                 match *literal {
                     Value { ref value } => Ok(self.const_to_ptr(value)?),
                     Item { def_id, substs } => {
-                        if ty.is_fn() {
+                        if let ty::TyFnDef(..) = ty.sty {
                             Err(EvalError::Unimplemented("unimplemented: mentions of function items".to_string()))
                         } else {
                             let cid = ConstantId {
index 587239fdf068db9a2dbe57ce1e9a2aab6986a58e..db7b129eee601db020aadf4eaffd301109a04313 100644 (file)
@@ -8,7 +8,7 @@
 };
 use error::EvalResult;
 use rustc::mir::repr as mir;
-use rustc::ty::subst;
+use rustc::ty::{subst, self};
 use rustc::hir::def_id::DefId;
 use rustc::mir::visit::{Visitor, LvalueContext};
 use syntax::codemap::Span;
@@ -151,7 +151,7 @@ fn visit_constant(&mut self, constant: &mir::Constant<'tcx>) {
             // already computed by rustc
             mir::Literal::Value { .. } => {}
             mir::Literal::Item { def_id, substs } => {
-                if constant.ty.is_fn() {
+                if let ty::TyFnDef(..) = constant.ty.sty {
                     // No need to do anything here, even if function pointers are implemented,
                     // 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`