Rework diagnostics for wrong number of generic args

This commit is contained in:
Patryk Wychowaniec
2021-01-02 19:45:11 +01:00
parent 34628e5b53
commit d2f8e398f1
121 changed files with 2787 additions and 766 deletions

View File

@@ -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;