@@ -4809,9 +4809,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
48094809        // variables. If the user provided some types, we may still need 
48104810        // to add defaults. If the user provided *too many* types, that's 
48114811        // a problem. 
4812-         self . check_path_parameter_count ( span,  & mut  type_segment ,   false ) ; 
4813-         self . check_path_parameter_count ( span,  & mut  fn_segment ,  false ) ; 
4814-         self . check_impl_trait ( span,  & mut  fn_segment) ; 
4812+         let  supress_mismatch =  self . check_impl_trait ( span,  & mut  fn_segment ) ; 
4813+         self . check_path_parameter_count ( span,  & mut  type_segment ,  false ,  supress_mismatch ) ; 
4814+         self . check_path_parameter_count ( span,  & mut  fn_segment,   false ,  supress_mismatch ) ; 
48154815
48164816        let  ( fn_start,  has_self)  = match  ( type_segment,  fn_segment)  { 
48174817            ( _,  Some ( ( _,  generics) ) )  => { 
@@ -4964,7 +4964,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
49644964fn  check_path_parameter_count ( & self , 
49654965                                  span :  Span , 
49664966                                  segment :  & mut  Option < ( & hir:: PathSegment ,  & ty:: Generics ) > , 
4967-                                   is_method_call :  bool )  { 
4967+                                   is_method_call :  bool , 
4968+                                   supress_mismatch_error :  bool )  { 
49684969        let  ( lifetimes,  types,  infer_types,  bindings)  = segment. map_or ( 
49694970            ( & [ ] [ ..] ,  & [ ] [ ..] ,  true ,  & [ ] [ ..] ) , 
49704971            |( s,  _) | s. parameters . as_ref ( ) . map_or ( 
@@ -5004,7 +5005,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
50045005            // type parameters, we force instantiate_value_path to 
50055006            // use inference variables instead of the provided types. 
50065007            * segment = None ; 
5007-         }  else  if  types. len ( )  < required_len && !infer_types { 
5008+         }  else  if  types. len ( )  < required_len && !infer_types && !supress_mismatch_error  { 
50085009            let  expected_text = count_type_params ( required_len) ; 
50095010            let  actual_text = count_type_params ( types. len ( ) ) ; 
50105011            struct_span_err ! ( self . tcx. sess,  span,  E0089 , 
@@ -5071,10 +5072,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
50715072    /// Report error if there is an explicit type parameter when using `impl Trait`. 
50725073fn  check_impl_trait ( & self , 
50735074                        span :  Span , 
5074-                         segment :  & mut  Option < ( & hir:: PathSegment ,  & ty:: Generics ) > )  { 
5075+                         segment :  & mut  Option < ( & hir:: PathSegment ,  & ty:: Generics ) > ) 
5076+                         -> bool  { 
50755077        use  hir:: SyntheticTyParamKind :: * ; 
50765078
5077-         segment. map ( |( path_segment,  generics) | { 
5079+         let  segment =  segment. map ( |( path_segment,  generics) | { 
50785080            let  explicit = !path_segment. infer_types ; 
50795081            let  impl_trait = generics. types . iter ( ) 
50805082                                           . any ( |ty_param| { 
@@ -5095,7 +5097,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
50955097
50965098                err. emit ( ) ; 
50975099            } 
5100+ 
5101+             impl_trait
50985102        } ) ; 
5103+ 
5104+         segment. unwrap_or ( false ) 
50995105    } 
51005106
51015107    // Resolves `typ` by a single level if `typ` is a type variable. 
0 commit comments