@@ -136,10 +136,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
136136 AngleBrackets :: Missing => 0 ,
137137 // Only lifetime arguments can be implied
138138 AngleBrackets :: Implied => self . gen_args . args . len ( ) ,
139- AngleBrackets :: Available => self . gen_args . args . iter ( ) . fold ( 0 , |acc, arg| match arg {
140- hir:: GenericArg :: Lifetime ( _) => acc + 1 ,
141- _ => acc,
142- } ) ,
139+ AngleBrackets :: Available => self . gen_args . num_lifetime_params ( ) ,
143140 }
144141 }
145142
@@ -148,10 +145,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
148145 AngleBrackets :: Missing => 0 ,
149146 // Only lifetime arguments can be implied
150147 AngleBrackets :: Implied => 0 ,
151- AngleBrackets :: Available => self . gen_args . args . iter ( ) . fold ( 0 , |acc, arg| match arg {
152- hir:: GenericArg :: Type ( _) | hir:: GenericArg :: Const ( _) => acc + 1 ,
153- _ => acc,
154- } ) ,
148+ AngleBrackets :: Available => self . gen_args . num_generic_params ( ) ,
155149 }
156150 }
157151
@@ -651,7 +645,9 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
651645 let mut found_redundant = false ;
652646 for arg in self . gen_args . args {
653647 match arg {
654- hir:: GenericArg :: Type ( _) | hir:: GenericArg :: Const ( _) => {
648+ hir:: GenericArg :: Type ( _)
649+ | hir:: GenericArg :: Const ( _)
650+ | hir:: GenericArg :: Infer ( _) => {
655651 gen_arg_spans. push ( arg. span ( ) ) ;
656652 if gen_arg_spans. len ( ) > self . num_expected_type_or_const_args ( ) {
657653 found_redundant = true ;
0 commit comments