implement creating generics for impl traits in associated types

This commit is contained in:
dfireBird 2024-04-29 23:55:02 +05:30
parent f216be4a07
commit 40a677ddf0
No known key found for this signature in database
GPG key ID: 26D522CA5FC2B93D
6 changed files with 102 additions and 17 deletions

View file

@ -339,6 +339,7 @@ impl GenericParamsCollector {
target: Either<TypeRef, LifetimeRef>,
) {
let bound = TypeBound::from_ast(lower_ctx, bound);
self.fill_impl_trait_bounds(lower_ctx.take_impl_traits_bounds());
let predicate = match (target, bound) {
(Either::Left(type_ref), bound) => match hrtb_lifetimes {
Some(hrtb_lifetimes) => WherePredicate::ForLifetime {
@ -359,6 +360,23 @@ impl GenericParamsCollector {
self.where_predicates.push(predicate);
}
fn fill_impl_trait_bounds(&mut self, impl_bounds: Vec<Vec<Interned<TypeBound>>>) {
for bounds in impl_bounds {
let param = TypeParamData {
name: None,
default: None,
provenance: TypeParamProvenance::ArgumentImplTrait,
};
let param_id = self.type_or_consts.alloc(param.into());
for bound in bounds {
self.where_predicates.push(WherePredicate::TypeBound {
target: WherePredicateTypeTarget::TypeOrConstParam(param_id),
bound,
});
}
}
}
pub(crate) fn fill_implicit_impl_trait_args(
&mut self,
db: &dyn DefDatabase,