Skip to content

Commit 30d8323

Browse files
committed
Extend clauses.rs to support impl/dyn Trait
1 parent 36ddb8a commit 30d8323

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

chalk-solve/src/clauses.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,23 @@ fn program_clauses_that_could_match(
167167
}
168168
}
169169

170+
// Check for impl and dyn Traits so that we generate
171+
// `Implemented(impl Foo + Bar) :- Implemented(Foo), Implemented(Bar)`
172+
match trait_ref.self_type_parameter() {
173+
Some(Ty::Opaque(qwc)) | Some(Ty::Dyn(qwc)) => {
174+
clauses.push(ProgramClauseImplication {
175+
consequence: trait_ref.clone().cast(),
176+
conditions: qwc
177+
.value
178+
.iter()
179+
.cloned()
180+
.casted()
181+
.collect(),
182+
}.cast());
183+
}
184+
_ => {}
185+
}
186+
170187
// TODO sized, unsize_trait, builtin impls?
171188
}
172189
DomainGoal::Holds(WhereClause::ProjectionEq(projection_predicate)) => {

0 commit comments

Comments
 (0)