Fix handling of hir::GenericArg::Infer in wrong_number_of_generic_args.rs

This commit is contained in:
Fabian Wolff 2021-09-15 00:11:18 +02:00
parent c3c0f80d60
commit 2a2bfd1e59

View File

@ -136,10 +136,7 @@ fn num_provided_lifetime_args(&self) -> usize {
AngleBrackets::Missing => 0,
// Only lifetime arguments can be implied
AngleBrackets::Implied => self.gen_args.args.len(),
AngleBrackets::Available => self.gen_args.args.iter().fold(0, |acc, arg| match arg {
hir::GenericArg::Lifetime(_) => acc + 1,
_ => acc,
}),
AngleBrackets::Available => self.gen_args.num_lifetime_params(),
}
}
@ -148,10 +145,7 @@ fn num_provided_type_or_const_args(&self) -> usize {
AngleBrackets::Missing => 0,
// Only lifetime arguments can be implied
AngleBrackets::Implied => 0,
AngleBrackets::Available => self.gen_args.args.iter().fold(0, |acc, arg| match arg {
hir::GenericArg::Type(_) | hir::GenericArg::Const(_) => acc + 1,
_ => acc,
}),
AngleBrackets::Available => self.gen_args.num_generic_params(),
}
}
@ -651,7 +645,9 @@ fn suggest_removing_args_or_generics(&self, err: &mut DiagnosticBuilder<'_>) {
let mut found_redundant = false;
for arg in self.gen_args.args {
match arg {
hir::GenericArg::Type(_) | hir::GenericArg::Const(_) => {
hir::GenericArg::Type(_)
| hir::GenericArg::Const(_)
| hir::GenericArg::Infer(_) => {
gen_arg_spans.push(arg.span());
if gen_arg_spans.len() > self.num_expected_type_or_const_args() {
found_redundant = true;