Fix compilation of other crates

This commit is contained in:
Florian Diebold
2020-02-04 21:33:03 +01:00
committed by Florian Diebold
parent a3d8cffde3
commit 0718682cff
3 changed files with 25 additions and 14 deletions

View File

@@ -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<GenericDefId>) -> Substs {
let params = generics(db, def.into());
Substs::type_params_for_generics(&params)
}
/// 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::<Vec<_>>(), f)?;
}
}