mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 14:21:44 +00:00
Make GenericParams::type_or_consts private
This commit is contained in:
parent
73c97e3fe0
commit
372e2d22e6
11 changed files with 239 additions and 233 deletions
|
@ -452,7 +452,7 @@ impl HirDisplay for TypeOrConstParam {
|
|||
impl HirDisplay for TypeParam {
|
||||
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
|
||||
let params = f.db.generic_params(self.id.parent());
|
||||
let param_data = ¶ms.type_or_consts[self.id.local_id()];
|
||||
let param_data = ¶ms[self.id.local_id()];
|
||||
let substs = TyBuilder::placeholder_subst(f.db, self.id.parent());
|
||||
let krate = self.id.parent().krate(f.db).id;
|
||||
let ty =
|
||||
|
@ -540,10 +540,9 @@ fn write_generic_params(
|
|||
) -> Result<(), HirDisplayError> {
|
||||
let params = f.db.generic_params(def);
|
||||
if params.lifetimes.is_empty()
|
||||
&& params.type_or_consts.iter().all(|it| it.1.const_param().is_none())
|
||||
&& params.iter_type_or_consts().all(|it| it.1.const_param().is_none())
|
||||
&& params
|
||||
.type_or_consts
|
||||
.iter()
|
||||
.iter_type_or_consts()
|
||||
.filter_map(|it| it.1.type_param())
|
||||
.all(|param| !matches!(param.provenance, TypeParamProvenance::TypeParamList))
|
||||
{
|
||||
|
@ -564,7 +563,7 @@ fn write_generic_params(
|
|||
delim(f)?;
|
||||
write!(f, "{}", lifetime.name.display(f.db.upcast()))?;
|
||||
}
|
||||
for (_, ty) in params.type_or_consts.iter() {
|
||||
for (_, ty) in params.iter_type_or_consts() {
|
||||
if let Some(name) = &ty.name() {
|
||||
match ty {
|
||||
TypeOrConstParamData::TypeParamData(ty) => {
|
||||
|
@ -616,7 +615,7 @@ fn has_disaplayable_predicates(params: &Interned<GenericParams>) -> bool {
|
|||
!matches!(
|
||||
pred,
|
||||
WherePredicate::TypeBound { target: WherePredicateTypeTarget::TypeOrConstParam(id), .. }
|
||||
if params.type_or_consts[*id].name().is_none()
|
||||
if params[*id].name().is_none()
|
||||
)
|
||||
})
|
||||
}
|
||||
|
@ -631,13 +630,13 @@ fn write_where_predicates(
|
|||
let is_unnamed_type_target =
|
||||
|params: &Interned<GenericParams>, target: &WherePredicateTypeTarget| {
|
||||
matches!(target,
|
||||
WherePredicateTypeTarget::TypeOrConstParam(id) if params.type_or_consts[*id].name().is_none()
|
||||
WherePredicateTypeTarget::TypeOrConstParam(id) if params[*id].name().is_none()
|
||||
)
|
||||
};
|
||||
|
||||
let write_target = |target: &WherePredicateTypeTarget, f: &mut HirFormatter<'_>| match target {
|
||||
WherePredicateTypeTarget::TypeRef(ty) => ty.hir_fmt(f),
|
||||
WherePredicateTypeTarget::TypeOrConstParam(id) => match params.type_or_consts[*id].name() {
|
||||
WherePredicateTypeTarget::TypeOrConstParam(id) => match params[*id].name() {
|
||||
Some(name) => write!(f, "{}", name.display(f.db.upcast())),
|
||||
None => f.write_str("{unnamed}"),
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue