Skip to content

Commit

Permalink
make sure globals that yield function pointers aren't treated like fu…
Browse files Browse the repository at this point in the history
…nctions
  • Loading branch information
oli-obk committed Jun 9, 2016
1 parent 225a6a2 commit 040a501
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/interpreter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,7 @@ impl<'a, 'b, 'mir, 'tcx> FnEvalContext<'a, 'b, 'mir, 'tcx> {
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 {
Expand Down
4 changes: 2 additions & 2 deletions src/interpreter/stepper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use super::{
};
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;
Expand Down Expand Up @@ -151,7 +151,7 @@ impl<'a, 'b, 'mir, 'tcx> Visitor<'tcx> for ConstantExtractor<'a, 'b, 'mir, '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`
Expand Down

0 comments on commit 040a501

Please sign in to comment.