Skip to content

Commit

Permalink
Merge pull request #226 from dwrensha/rustup
Browse files Browse the repository at this point in the history
update for upstream changes to TyFnDef
  • Loading branch information
oli-obk authored Jun 29, 2017
2 parents 695f972 + 73ab5c7 commit 4a56083
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
14 changes: 8 additions & 6 deletions src/eval_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
}

ReifyFnPointer => match self.operand_ty(operand).sty {
ty::TyFnDef(def_id, substs, _) => {
ty::TyFnDef(def_id, substs) => {
let instance = resolve(self.tcx, def_id, substs);
let fn_ptr = self.memory.create_fn_alloc(instance);
self.write_value(Value::ByVal(PrimVal::Ptr(fn_ptr)), dest, dest_ty)?;
Expand Down Expand Up @@ -1686,7 +1686,7 @@ pub fn eval_main<'a, 'tcx: 'a>(
let main_ptr = ecx.memory.create_fn_alloc(main_instance);
let dest = ecx.eval_lvalue(&mir::Lvalue::Local(args.next().unwrap()))?;
let main_ty = main_instance.def.def_ty(ecx.tcx);
let main_ptr_ty = ecx.tcx.mk_fn_ptr(main_ty.fn_sig());
let main_ptr_ty = ecx.tcx.mk_fn_ptr(main_ty.fn_sig(ecx.tcx));
ecx.write_value(Value::ByVal(PrimVal::Ptr(main_ptr)), dest, main_ptr_ty)?;

// Second argument (argc): 0
Expand Down Expand Up @@ -1830,7 +1830,7 @@ fn fn_once_adapter_instance<'a, 'tcx>(
let self_ty = tcx.mk_closure_from_closure_substs(
closure_did, substs);

let sig = tcx.closure_type(closure_did).subst(tcx, substs.substs);
let sig = tcx.fn_sig(closure_did).subst(tcx, substs.substs);
let sig = tcx.erase_late_bound_regions_and_normalize(&sig);
assert_eq!(sig.inputs().len(), 1);
let substs = tcx.mk_substs([
Expand Down Expand Up @@ -1891,9 +1891,11 @@ pub fn resolve<'a, 'tcx>(
} else {
let item_type = def_ty(tcx, def_id, substs);
let def = match item_type.sty {
ty::TyFnDef(_, _, f) if
f.abi() == Abi::RustIntrinsic ||
f.abi() == Abi::PlatformIntrinsic =>
ty::TyFnDef(..) if {
let f = item_type.fn_sig(tcx);
f.abi() == Abi::RustIntrinsic ||
f.abi() == Abi::PlatformIntrinsic
} =>
{
debug!(" => intrinsic");
ty::InstanceDef::Intrinsic(def_id)
Expand Down
6 changes: 4 additions & 2 deletions src/terminator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
let instance_ty = instance.def.def_ty(self.tcx);
let instance_ty = self.monomorphize(instance_ty, instance.substs);
match instance_ty.sty {
ty::TyFnDef(_, _, real_sig) => {
ty::TyFnDef(..) => {
let real_sig = instance_ty.fn_sig(self.tcx);
let sig = self.erase_lifetimes(&sig);
let real_sig = self.erase_lifetimes(&real_sig);
let real_sig = self.tcx.normalize_associated_type(&real_sig);
if !self.check_sig_compat(sig, real_sig)? {
return Err(EvalError::FunctionPointerTyMismatch(real_sig, sig));
}
Expand All @@ -83,7 +85,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
}
(instance, sig)
},
ty::TyFnDef(def_id, substs, sig) => (::eval_context::resolve(self.tcx, def_id, substs), sig),
ty::TyFnDef(def_id, substs) => (::eval_context::resolve(self.tcx, def_id, substs), func_ty.fn_sig(self.tcx)),
_ => {
let msg = format!("can't handle callee of type {:?}", func_ty);
return Err(EvalError::Unimplemented(msg));
Expand Down

0 comments on commit 4a56083

Please sign in to comment.