@@ -4984,10 +4984,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
4984
4984
// to add defaults. If the user provided *too many* types, that's
4985
4985
// a problem.
4986
4986
let mut infer_lifetimes = FxHashMap ( ) ;
4987
- let supress_mismatch = self . check_impl_trait ( span, fn_segment) ;
4988
4987
for & PathSeg ( def_id, index) in & path_segs {
4989
- let generics = self . tcx . generics_of ( def_id) ;
4990
4988
let seg = & segments[ index] ;
4989
+ let generics = self . tcx . generics_of ( def_id) ;
4990
+ let supress_mismatch = self . check_impl_trait ( span, seg, & generics) ;
4991
4991
self . check_generic_arg_count ( span, seg, & generics, false , supress_mismatch) ;
4992
4992
infer_lifetimes. insert ( index, if let Some ( ref data) = seg. args {
4993
4993
!data. args . iter ( ) . any ( |arg| match arg {
@@ -5284,33 +5284,30 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
5284
5284
/// Report error if there is an explicit type parameter when using `impl Trait`.
5285
5285
fn check_impl_trait ( & self ,
5286
5286
span : Span ,
5287
- segment : Option < ( & hir:: PathSegment , & ty:: Generics ) > )
5287
+ seg : & hir:: PathSegment ,
5288
+ generics : & ty:: Generics )
5288
5289
-> bool {
5289
- let segment = segment. map ( |( path_segment, generics) | {
5290
- let explicit = !path_segment. infer_types ;
5291
- let impl_trait = generics. params . iter ( ) . any ( |param| match param. kind {
5292
- ty:: GenericParamDefKind :: Type {
5293
- synthetic : Some ( hir:: SyntheticTyParamKind :: ImplTrait ) , ..
5294
- } => true ,
5295
- _ => false ,
5296
- } ) ;
5297
-
5298
- if explicit && impl_trait {
5299
- let mut err = struct_span_err ! {
5300
- self . tcx. sess,
5301
- span,
5302
- E0632 ,
5303
- "cannot provide explicit type parameters when `impl Trait` is \
5304
- used in argument position."
5305
- } ;
5290
+ let explicit = !seg. infer_types ;
5291
+ let impl_trait = generics. params . iter ( ) . any ( |param| match param. kind {
5292
+ ty:: GenericParamDefKind :: Type {
5293
+ synthetic : Some ( hir:: SyntheticTyParamKind :: ImplTrait ) , ..
5294
+ } => true ,
5295
+ _ => false ,
5296
+ } ) ;
5306
5297
5307
- err. emit ( ) ;
5308
- }
5298
+ if explicit && impl_trait {
5299
+ let mut err = struct_span_err ! {
5300
+ self . tcx. sess,
5301
+ span,
5302
+ E0632 ,
5303
+ "cannot provide explicit type parameters when `impl Trait` is \
5304
+ used in argument position."
5305
+ } ;
5309
5306
5310
- impl_trait
5311
- } ) ;
5307
+ err . emit ( ) ;
5308
+ }
5312
5309
5313
- segment . unwrap_or ( false )
5310
+ impl_trait
5314
5311
}
5315
5312
5316
5313
// Resolves `typ` by a single level if `typ` is a type variable.
0 commit comments