Show only assoc type args in the correct arg pos

This commit is contained in:
Hongxu Xu 2022-07-06 22:58:27 +08:00
parent 441e659aa1
commit 0f2eba54db
3 changed files with 69 additions and 3 deletions

View file

@ -41,6 +41,7 @@ use hir_def::{
adt::{ReprKind, VariantData},
body::{BodyDiagnostic, SyntheticSyntax},
expr::{BindingAnnotation, LabelId, Pat, PatId},
generics::{TypeOrConstParamData, TypeParamProvenance},
item_tree::ItemTreeNode,
lang_item::LangItemTarget,
nameres::{self, diagnostics::DefDiagnostic},
@ -1707,6 +1708,22 @@ impl Trait {
pub fn is_unsafe(&self, db: &dyn HirDatabase) -> bool {
db.trait_data(self.id).is_unsafe
}
pub fn type_parameters(&self, db: &dyn HirDatabase) -> Vec<TypeOrConstParamData> {
db.generic_params(GenericDefId::from(self.id))
.type_or_consts
.iter()
.filter(|(_, ty)| match ty {
TypeOrConstParamData::TypeParamData(ty)
if ty.provenance != TypeParamProvenance::TypeParamList =>
{
false
}
_ => true,
})
.map(|(_, ty)|ty.clone())
.collect()
}
}
impl HasVisibility for Trait {