Skip to content

Commit 644d639

Browse files
committed
typeck: Use TyFnDef for methods.
1 parent 847f007 commit 644d639

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

src/librustc_typeck/check/method/confirm.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,27 +98,29 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> {
9898
let InstantiatedMethodSig {
9999
method_sig, all_substs, method_predicates
100100
} = self.instantiate_method_sig(&pick, all_substs);
101+
let all_substs = self.tcx().mk_substs(all_substs);
101102
let method_self_ty = method_sig.inputs[0];
102103

103104
// Unify the (adjusted) self type with what the method expects.
104105
self.unify_receivers(self_ty, method_self_ty);
105106

106107
// Create the method type
108+
let def_id = pick.item.def_id();
107109
let method_ty = pick.item.as_opt_method().unwrap();
108-
let fty = self.tcx().mk_fn_ptr(ty::BareFnTy {
110+
let fty = self.tcx().mk_fn_def(def_id, all_substs, ty::BareFnTy {
109111
sig: ty::Binder(method_sig),
110112
unsafety: method_ty.fty.unsafety,
111113
abi: method_ty.fty.abi.clone(),
112114
});
113115

114116
// Add any trait/regions obligations specified on the method's type parameters.
115-
self.add_obligations(fty, &all_substs, &method_predicates);
117+
self.add_obligations(fty, all_substs, &method_predicates);
116118

117119
// Create the final `MethodCallee`.
118120
let callee = ty::MethodCallee {
119-
def_id: pick.item.def_id(),
121+
def_id: def_id,
120122
ty: fty,
121-
substs: self.tcx().mk_substs(all_substs)
123+
substs: all_substs
122124
};
123125
// If this is an `&mut self` method, bias the receiver
124126
// expression towards mutability (this will switch
@@ -457,7 +459,7 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> {
457459
fn fixup_derefs_on_method_receiver_if_necessary(&self,
458460
method_callee: &ty::MethodCallee) {
459461
let sig = match method_callee.ty.sty {
460-
ty::TyFnPtr(ref f) => f.sig.clone(),
462+
ty::TyFnDef(_, _, ref f) => f.sig.clone(),
461463
_ => return,
462464
};
463465

src/librustc_typeck/check/method/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
230230
&method_ty.fty.sig).0;
231231
let fn_sig = fcx.instantiate_type_scheme(span, trait_ref.substs, &fn_sig);
232232
let transformed_self_ty = fn_sig.inputs[0];
233-
let fty = tcx.mk_fn_ptr(ty::BareFnTy {
233+
let def_id = method_item.def_id();
234+
let fty = tcx.mk_fn_def(def_id, trait_ref.substs, ty::BareFnTy {
234235
sig: ty::Binder(fn_sig),
235236
unsafety: method_ty.fty.unsafety,
236237
abi: method_ty.fty.abi.clone(),
@@ -318,7 +319,7 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
318319
}
319320

320321
let callee = ty::MethodCallee {
321-
def_id: method_item.def_id(),
322+
def_id: def_id,
322323
ty: fty,
323324
substs: trait_ref.substs
324325
};

src/librustc_typeck/check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2340,7 +2340,7 @@ fn check_method_argument_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
23402340
ty::FnConverging(fcx.tcx().types.err)
23412341
} else {
23422342
match method_fn_ty.sty {
2343-
ty::TyFnPtr(ref fty) => {
2343+
ty::TyFnDef(_, _, ref fty) => {
23442344
// HACK(eddyb) ignore self in the definition (see above).
23452345
let expected_arg_tys = expected_types_for_fn_args(fcx,
23462346
sp,

0 commit comments

Comments
 (0)