@@ -44,15 +44,15 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
44
44
call_expr : & ' gcx hir:: Expr ,
45
45
unadjusted_self_ty : Ty < ' tcx > ,
46
46
pick : probe:: Pick < ' tcx > ,
47
- supplied_method_types : Vec < Ty < ' tcx > > )
47
+ segment : & hir :: PathSegment )
48
48
-> MethodCallee < ' tcx > {
49
- debug ! ( "confirm(unadjusted_self_ty={:?}, pick={:?}, supplied_method_types ={:?})" ,
49
+ debug ! ( "confirm(unadjusted_self_ty={:?}, pick={:?}, generic_args ={:?})" ,
50
50
unadjusted_self_ty,
51
51
pick,
52
- supplied_method_types ) ;
52
+ segment . parameters ) ;
53
53
54
54
let mut confirm_cx = ConfirmContext :: new ( self , span, self_expr, call_expr) ;
55
- confirm_cx. confirm ( unadjusted_self_ty, pick, supplied_method_types )
55
+ confirm_cx. confirm ( unadjusted_self_ty, pick, segment )
56
56
}
57
57
}
58
58
@@ -73,7 +73,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
73
73
fn confirm ( & mut self ,
74
74
unadjusted_self_ty : Ty < ' tcx > ,
75
75
pick : probe:: Pick < ' tcx > ,
76
- supplied_method_types : Vec < Ty < ' tcx > > )
76
+ segment : & hir :: PathSegment )
77
77
-> MethodCallee < ' tcx > {
78
78
// Adjust the self expression the user provided and obtain the adjusted type.
79
79
let self_ty = self . adjust_self_ty ( unadjusted_self_ty, & pick) ;
@@ -83,7 +83,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
83
83
84
84
// Create substitutions for the method's type parameters.
85
85
let rcvr_substs = self . fresh_receiver_substs ( self_ty, & pick) ;
86
- let all_substs = self . instantiate_method_substs ( & pick, supplied_method_types , rcvr_substs) ;
86
+ let all_substs = self . instantiate_method_substs ( & pick, segment , rcvr_substs) ;
87
87
88
88
debug ! ( "all_substs={:?}" , all_substs) ;
89
89
@@ -279,9 +279,14 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
279
279
280
280
fn instantiate_method_substs ( & mut self ,
281
281
pick : & probe:: Pick < ' tcx > ,
282
- mut supplied_method_types : Vec < Ty < ' tcx > > ,
282
+ segment : & hir :: PathSegment ,
283
283
substs : & Substs < ' tcx > )
284
284
-> & ' tcx Substs < ' tcx > {
285
+ let supplied_method_types = match segment. parameters {
286
+ hir:: AngleBracketedParameters ( ref data) => & data. types ,
287
+ _ => bug ! ( "unexpected generic arguments: {:?}" , segment. parameters) ,
288
+ } ;
289
+
285
290
// Determine the values for the generic parameters of the method.
286
291
// If they were not explicitly supplied, just construct fresh
287
292
// variables.
@@ -312,7 +317,6 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
312
317
num_method_types) )
313
318
. emit ( ) ;
314
319
}
315
- supplied_method_types = vec ! [ self . tcx. types. err; num_method_types] ;
316
320
}
317
321
318
322
// Create subst for early-bound lifetime parameters, combining
@@ -331,10 +335,10 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
331
335
let i = def. index as usize ;
332
336
if i < substs. len ( ) {
333
337
substs. type_at ( i)
334
- } else if supplied_method_types. is_empty ( ) {
335
- self . type_var_for_def ( self . span , def , cur_substs )
338
+ } else if let Some ( ast_ty ) = supplied_method_types. get ( i - supplied_start ) {
339
+ self . to_ty ( ast_ty )
336
340
} else {
337
- supplied_method_types [ i - supplied_start ]
341
+ self . type_var_for_def ( self . span , def , cur_substs )
338
342
}
339
343
} )
340
344
}
0 commit comments