Skip to content

Commit b2b82f7

Browse files
committed
Implement AggregateOps
`make_solution` does not return any guidance for now
1 parent 0169dc3 commit b2b82f7

File tree

1 file changed

+28
-2
lines changed
  • src/librustc_traits/chalk_context

1 file changed

+28
-2
lines changed

src/librustc_traits/chalk_context/mod.rs

+28-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use rustc::infer::canonical::{
2626
CanonicalVarValues,
2727
OriginalQueryValues,
2828
QueryResponse,
29+
Certainty,
2930
};
3031
use rustc::traits::{
3132
DomainGoal,
@@ -132,9 +133,34 @@ impl context::AggregateOps<ChalkArenas<'gcx>> for ChalkContext<'cx, 'gcx> {
132133
fn make_solution(
133134
&self,
134135
_root_goal: &Canonical<'gcx, InEnvironment<'gcx, Goal<'gcx>>>,
135-
_simplified_answers: impl context::AnswerStream<ChalkArenas<'gcx>>,
136+
mut simplified_answers: impl context::AnswerStream<ChalkArenas<'gcx>>,
136137
) -> Option<Canonical<'gcx, QueryResponse<'gcx, ()>>> {
137-
unimplemented!()
138+
use chalk_engine::SimplifiedAnswer;
139+
140+
if simplified_answers.peek_answer().is_none() {
141+
return None;
142+
}
143+
144+
let SimplifiedAnswer { subst, ambiguous } = simplified_answers
145+
.next_answer()
146+
.unwrap();
147+
148+
let ambiguous = simplified_answers.peek_answer().is_some() || ambiguous;
149+
150+
Some(subst.unchecked_map(|subst| {
151+
QueryResponse {
152+
var_values: subst.subst,
153+
region_constraints: subst.constraints
154+
.into_iter()
155+
.map(|c| ty::Binder::bind(c))
156+
.collect(),
157+
certainty: match ambiguous {
158+
true => Certainty::Ambiguous,
159+
false => Certainty::Proven,
160+
},
161+
value: (),
162+
}
163+
}))
138164
}
139165
}
140166

0 commit comments

Comments
 (0)