From 0718682cffaae34e5c106c793c60f6706fc04b05 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Tue, 4 Feb 2020 21:33:03 +0100 Subject: Fix compilation of other crates --- crates/ra_hir_ty/src/lib.rs | 10 ++++++++-- crates/ra_hir_ty/src/lower.rs | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'crates/ra_hir_ty/src') diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs index a685e70c2..314be17b8 100644 --- a/crates/ra_hir_ty/src/lib.rs +++ b/crates/ra_hir_ty/src/lib.rs @@ -361,10 +361,16 @@ impl Substs { } /// Return Substs that replace each parameter by itself (i.e. `Ty::Param`). - pub(crate) fn type_params(generic_params: &Generics) -> Substs { + pub(crate) fn type_params_for_generics(generic_params: &Generics) -> Substs { Substs(generic_params.iter().map(|(id, _)| Ty::Param(id)).collect()) } + /// Return Substs that replace each parameter by itself (i.e. `Ty::Param`). + pub fn type_params(db: &impl HirDatabase, def: impl Into) -> Substs { + let params = generics(db, def.into()); + Substs::type_params_for_generics(¶ms) + } + /// Return Substs that replace each parameter by a bound variable. pub(crate) fn bound_vars(generic_params: &Generics) -> Substs { Substs(generic_params.iter().enumerate().map(|(idx, _)| Ty::Bound(idx as u32)).collect()) @@ -1026,7 +1032,7 @@ impl HirDisplay for Ty { TypeParamProvenance::ArgumentImplTrait => { write!(f, "impl ")?; let bounds = f.db.generic_predicates_for_param(*id); - let substs = Substs::type_params(&generics); + let substs = Substs::type_params_for_generics(&generics); write_bounds_like_dyn_trait(&bounds.iter().map(|b| b.clone().subst(&substs)).collect::>(), f)?; } } diff --git a/crates/ra_hir_ty/src/lower.rs b/crates/ra_hir_ty/src/lower.rs index 847111748..0d4c075af 100644 --- a/crates/ra_hir_ty/src/lower.rs +++ b/crates/ra_hir_ty/src/lower.rs @@ -276,7 +276,7 @@ impl Ty { TypeNs::SelfType(impl_id) => { let generics = generics(ctx.db, impl_id.into()); let substs = match ctx.type_param_mode { - TypeParamLoweringMode::Placeholder => Substs::type_params(&generics), + TypeParamLoweringMode::Placeholder => Substs::type_params_for_generics(&generics), TypeParamLoweringMode::Variable => Substs::bound_vars(&generics), }; ctx.db.impl_self_ty(impl_id).subst(&substs) @@ -284,7 +284,7 @@ impl Ty { TypeNs::AdtSelfType(adt) => { let generics = generics(ctx.db, adt.into()); let substs = match ctx.type_param_mode { - TypeParamLoweringMode::Placeholder => Substs::type_params(&generics), + TypeParamLoweringMode::Placeholder => Substs::type_params_for_generics(&generics), TypeParamLoweringMode::Variable => Substs::bound_vars(&generics), }; ctx.db.ty(adt.into()).subst(&substs) -- cgit v1.2.3