@@ -4764,9 +4764,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
47644764 // variables. If the user provided some types, we may still need
47654765 // to add defaults. If the user provided *too many* types, that's
47664766 // a problem.
4767- self . check_path_parameter_count ( span, & mut type_segment , false ) ;
4768- self . check_path_parameter_count ( span, & mut fn_segment , false ) ;
4769- self . check_impl_trait ( span, & mut fn_segment) ;
4767+ let supress_mismatch = self . check_impl_trait ( span, & mut fn_segment ) ;
4768+ self . check_path_parameter_count ( span, & mut type_segment , false , supress_mismatch ) ;
4769+ self . check_path_parameter_count ( span, & mut fn_segment, false , supress_mismatch ) ;
47704770
47714771 let ( fn_start, has_self) = match ( type_segment, fn_segment) {
47724772 ( _, Some ( ( _, generics) ) ) => {
@@ -4919,7 +4919,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
49194919 fn check_path_parameter_count ( & self ,
49204920 span : Span ,
49214921 segment : & mut Option < ( & hir:: PathSegment , & ty:: Generics ) > ,
4922- is_method_call : bool ) {
4922+ is_method_call : bool ,
4923+ supress_mismatch_error : bool ) {
49234924 let ( lifetimes, types, infer_types, bindings) = segment. map_or (
49244925 ( & [ ] [ ..] , & [ ] [ ..] , true , & [ ] [ ..] ) ,
49254926 |( s, _) | s. parameters . as_ref ( ) . map_or (
@@ -4959,7 +4960,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
49594960 // type parameters, we force instantiate_value_path to
49604961 // use inference variables instead of the provided types.
49614962 * segment = None ;
4962- } else if types. len ( ) < required_len && !infer_types {
4963+ } else if types. len ( ) < required_len && !infer_types && !supress_mismatch_error {
49634964 let expected_text = count_type_params ( required_len) ;
49644965 let actual_text = count_type_params ( types. len ( ) ) ;
49654966 struct_span_err ! ( self . tcx. sess, span, E0089 ,
@@ -5026,10 +5027,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
50265027 /// Report error if there is an explicit type parameter when using `impl Trait`.
50275028 fn check_impl_trait ( & self ,
50285029 span : Span ,
5029- segment : & mut Option < ( & hir:: PathSegment , & ty:: Generics ) > ) {
5030+ segment : & mut Option < ( & hir:: PathSegment , & ty:: Generics ) > )
5031+ -> bool {
50305032 use hir:: SyntheticTyParamKind :: * ;
50315033
5032- segment. map ( |( path_segment, generics) | {
5034+ let segment = segment. map ( |( path_segment, generics) | {
50335035 let explicit = !path_segment. infer_types ;
50345036 let impl_trait = generics. types . iter ( )
50355037 . any ( |ty_param| {
@@ -5050,7 +5052,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
50505052
50515053 err. emit ( ) ;
50525054 }
5055+
5056+ impl_trait
50535057 } ) ;
5058+
5059+ segment. unwrap_or ( false )
50545060 }
50555061
50565062 // Resolves `typ` by a single level if `typ` is a type variable.
0 commit comments