Store indices of generic args instead of spans, as the actual entries are unused, just the number of entries is checked.

The indices will be used in a follow-up commit
This commit is contained in:
Oli Scherer 2024-06-03 13:06:59 +00:00
parent 4dec6bbcb3
commit 24af952ef7
3 changed files with 5 additions and 16 deletions

View File

@ -702,7 +702,7 @@ pub(crate) fn complain_about_inherent_assoc_ty_not_found(
pub(crate) fn complain_about_missing_assoc_tys(
&self,
associated_types: FxIndexMap<Span, FxIndexSet<DefId>>,
potential_assoc_types: Vec<Span>,
potential_assoc_types: Vec<usize>,
trait_bounds: &[hir::PolyTraitRef<'_>],
) {
if associated_types.values().all(|v| v.is_empty()) {

View File

@ -474,16 +474,9 @@ pub(crate) fn check_generic_arg_count(
return Ok(());
}
if provided_args > max_expected_args {
invalid_args.extend(
gen_args.args[max_expected_args..provided_args].iter().map(|arg| arg.span()),
);
};
invalid_args.extend(min_expected_args..provided_args);
let gen_args_info = if provided_args > min_expected_args {
invalid_args.extend(
gen_args.args[min_expected_args..provided_args].iter().map(|arg| arg.span()),
);
let num_redundant_args = provided_args - min_expected_args;
GenericArgsInfo::ExcessLifetimes { num_redundant_args }
} else {
@ -538,11 +531,7 @@ pub(crate) fn check_generic_arg_count(
let num_default_params = expected_max - expected_min;
let gen_args_info = if provided > expected_max {
invalid_args.extend(
gen_args.args[args_offset + expected_max..args_offset + provided]
.iter()
.map(|arg| arg.span()),
);
invalid_args.extend((expected_max..provided).map(|i| i + args_offset));
let num_redundant_args = provided - expected_max;
// Provide extra note if synthetic arguments like `impl Trait` are specified.

View File

@ -218,8 +218,8 @@ pub(crate) enum GenericArgPosition {
#[derive(Clone, Debug)]
pub struct GenericArgCountMismatch {
pub reported: ErrorGuaranteed,
/// A list of spans of arguments provided that were not valid.
pub invalid_args: Vec<Span>,
/// A list of indices of arguments provided that were not valid.
pub invalid_args: Vec<usize>,
}
/// Decorates the result of a generic argument count mismatch