Auto merge of #77524 - Patryk27:fixes/66228, r=estebank
Rework diagnostics for wrong number of generic args (fixes #66228 and #71924) This PR reworks the `wrong number of {} arguments` message, so that it provides more details and contextual hints.
This commit is contained in:
@@ -871,19 +871,37 @@ impl<'tcx> Generics {
|
||||
// We could cache this as a property of `GenericParamCount`, but
|
||||
// the aim is to refactor this away entirely eventually and the
|
||||
// presence of this method will be a constant reminder.
|
||||
let mut own_counts: GenericParamCount = Default::default();
|
||||
let mut own_counts = GenericParamCount::default();
|
||||
|
||||
for param in &self.params {
|
||||
match param.kind {
|
||||
GenericParamDefKind::Lifetime => own_counts.lifetimes += 1,
|
||||
GenericParamDefKind::Type { .. } => own_counts.types += 1,
|
||||
GenericParamDefKind::Const => own_counts.consts += 1,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
own_counts
|
||||
}
|
||||
|
||||
pub fn own_defaults(&self) -> GenericParamCount {
|
||||
let mut own_defaults = GenericParamCount::default();
|
||||
|
||||
for param in &self.params {
|
||||
match param.kind {
|
||||
GenericParamDefKind::Lifetime => (),
|
||||
GenericParamDefKind::Type { has_default, .. } => {
|
||||
own_defaults.types += has_default as usize;
|
||||
}
|
||||
GenericParamDefKind::Const => {
|
||||
// FIXME(const_generics:defaults)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
own_defaults
|
||||
}
|
||||
|
||||
pub fn requires_monomorphization(&self, tcx: TyCtxt<'tcx>) -> bool {
|
||||
if self.own_requires_monomorphization() {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user