Skip to content

Commit f2ee9da

Browse files
committed
Fix solving <impl Trait as Trait>::AssocType
... if the `impl Trait` is represented as an `AliasTy` itself, instead of a placeholder. I couldn't actually write a test for this that fails here, because chalk-integration represents opaque types as placeholders (i.e. application types with `TypeName::OpaqueTy`) immediately, instead of using `AliasTy`. I'm not sure that's correct?
1 parent 80c17b8 commit f2ee9da

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
@@ -234,12 +234,15 @@ fn program_clauses_that_could_match<I: Interner>(
234234
.trait_ref_from_projection(proj)
235235
.self_type_parameter(interner);
236236

237-
if let TyData::Apply(ApplicationTy {
238-
name: TypeName::OpaqueType(opaque_ty_id),
239-
..
240-
}) = trait_self_ty.data(interner)
241-
{
242-
db.opaque_ty_data(*opaque_ty_id).to_program_clauses(builder)
237+
match trait_self_ty.data(interner) {
238+
TyData::Apply(ApplicationTy {
239+
name: TypeName::OpaqueType(opaque_ty_id),
240+
..
241+
})
242+
| TyData::Alias(AliasTy::Opaque(OpaqueTy { opaque_ty_id, .. })) => {
243+
db.opaque_ty_data(*opaque_ty_id).to_program_clauses(builder);
244+
}
245+
_ => {}
243246
}
244247

245248
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,5 +96,14 @@ 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
}

0 commit comments

Comments
 (0)