@@ -44,15 +44,15 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
4444 call_expr : & ' gcx hir:: Expr ,
4545 unadjusted_self_ty : Ty < ' tcx > ,
4646 pick : probe:: Pick < ' tcx > ,
47- supplied_method_types : Vec < Ty < ' tcx > > )
47+ segment : & hir :: PathSegment )
4848 -> MethodCallee < ' tcx > {
49- debug ! ( "confirm(unadjusted_self_ty={:?}, pick={:?}, supplied_method_types ={:?})" ,
49+ debug ! ( "confirm(unadjusted_self_ty={:?}, pick={:?}, generic_args ={:?})" ,
5050 unadjusted_self_ty,
5151 pick,
52- supplied_method_types ) ;
52+ segment . parameters ) ;
5353
5454 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 )
5656 }
5757}
5858
@@ -73,7 +73,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
7373 fn confirm ( & mut self ,
7474 unadjusted_self_ty : Ty < ' tcx > ,
7575 pick : probe:: Pick < ' tcx > ,
76- supplied_method_types : Vec < Ty < ' tcx > > )
76+ segment : & hir :: PathSegment )
7777 -> MethodCallee < ' tcx > {
7878 // Adjust the self expression the user provided and obtain the adjusted type.
7979 let self_ty = self . adjust_self_ty ( unadjusted_self_ty, & pick) ;
@@ -83,7 +83,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
8383
8484 // Create substitutions for the method's type parameters.
8585 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) ;
8787
8888 debug ! ( "all_substs={:?}" , all_substs) ;
8989
@@ -279,9 +279,14 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
279279
280280 fn instantiate_method_substs ( & mut self ,
281281 pick : & probe:: Pick < ' tcx > ,
282- mut supplied_method_types : Vec < Ty < ' tcx > > ,
282+ segment : & hir :: PathSegment ,
283283 substs : & Substs < ' tcx > )
284284 -> & ' 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+
285290 // Determine the values for the generic parameters of the method.
286291 // If they were not explicitly supplied, just construct fresh
287292 // variables.
@@ -312,7 +317,6 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
312317 num_method_types) )
313318 . emit ( ) ;
314319 }
315- supplied_method_types = vec ! [ self . tcx. types. err; num_method_types] ;
316320 }
317321
318322 // Create subst for early-bound lifetime parameters, combining
@@ -331,10 +335,10 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
331335 let i = def. index as usize ;
332336 if i < substs. len ( ) {
333337 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 )
336340 } else {
337- supplied_method_types [ i - supplied_start ]
341+ self . type_var_for_def ( self . span , def , cur_substs )
338342 }
339343 } )
340344 }
0 commit comments