fix: Fix impl Trait<Self> causing stackoverflows

This commit is contained in:
Lukas Wirth 2024-03-18 16:33:13 +01:00
parent 2cbc2841d8
commit 1915980031
11 changed files with 233 additions and 149 deletions

View file

@ -4711,10 +4711,12 @@ impl Type {
if let WhereClause::Implemented(trait_ref) = pred.skip_binders() {
cb(type_.clone());
// skip the self type. it's likely the type we just got the bounds from
for ty in
trait_ref.substitution.iter(Interner).skip(1).filter_map(|a| a.ty(Interner))
{
walk_type(db, &type_.derived(ty.clone()), cb);
if let [self_ty, params @ ..] = trait_ref.substitution.as_slice(Interner) {
for ty in
params.iter().filter(|&ty| ty != self_ty).filter_map(|a| a.ty(Interner))
{
walk_type(db, &type_.derived(ty.clone()), cb);
}
}
}
}