Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir/src/lib.rs')
-rw-r--r--crates/hir/src/lib.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index 38beb90b36..96424d087e 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -1709,7 +1709,11 @@ impl Trait {
db.trait_data(self.id).is_unsafe
}
- pub fn type_parameters(&self, db: &dyn HirDatabase) -> Vec<TypeOrConstParamData> {
+ pub fn type_or_const_param_count(
+ &self,
+ db: &dyn HirDatabase,
+ count_required_only: bool,
+ ) -> usize {
db.generic_params(GenericDefId::from(self.id))
.type_or_consts
.iter()
@@ -1721,9 +1725,9 @@ impl Trait {
}
_ => true,
})
- .map(|(_, ty)|ty.clone())
- .collect()
- }
+ .filter(|(_, ty)| !count_required_only || !ty.has_default())
+ .count()
+ }
}
impl HasVisibility for Trait {