Skip to content

Commit a9e2e0b

Browse files
authored
Merge pull request #473 from flodiebold/opaque-ty-alias-projection
Fix solving <impl Trait as Trait>::AssocType
2 parents e5aaf83 + f2ee9da commit a9e2e0b

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

chalk-solve/src/clauses.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,15 @@ fn program_clauses_that_could_match<I: Interner>(
304304
.trait_ref_from_projection(proj)
305305
.self_type_parameter(interner);
306306

307-
if let TyData::Apply(ApplicationTy {
308-
name: TypeName::OpaqueType(opaque_ty_id),
309-
..
310-
}) = trait_self_ty.data(interner)
311-
{
312-
db.opaque_ty_data(*opaque_ty_id).to_program_clauses(builder)
307+
match trait_self_ty.data(interner) {
308+
TyData::Apply(ApplicationTy {
309+
name: TypeName::OpaqueType(opaque_ty_id),
310+
..
311+
})
312+
| TyData::Alias(AliasTy::Opaque(OpaqueTy { opaque_ty_id, .. })) => {
313+
db.opaque_ty_data(*opaque_ty_id).to_program_clauses(builder);
314+
}
315+
_ => {}
313316
}
314317

315318
db.associated_ty_data(proj.associated_ty_id)

tests/test/opaque_types.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,15 @@ fn opaque_generics() {
9696
"Unique; substitution []"
9797
}
9898

99+
goal {
100+
exists<T> {
101+
<Foo<Bar> as Iterator>::Item = T
102+
}
103+
} yields[SolverChoice::slg_default()] {
104+
"Ambiguous" // #234
105+
} yields[SolverChoice::recursive()] {
106+
"Unique; substitution [?0 := Bar], lifetime constraints []"
107+
}
99108
}
100109
}
101110

0 commit comments

Comments
 (0)