Skip to content

Commit 2ee933d

Browse files
aravind-pgnikomatsakis
authored andcommitted
Simplify trait selector's evaluation API
1 parent e257271 commit 2ee933d

File tree

3 files changed

+8
-36
lines changed

3 files changed

+8
-36
lines changed

src/librustc/traits/coherence.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ fn overlap<'cx, 'gcx, 'tcx>(selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>,
156156
recursion_depth: 0,
157157
predicate: p })
158158
.chain(obligations)
159-
.find(|o| !selcx.evaluate_obligation(o));
160-
// FIXME: the call to `selcx.evaluate_obligation` above should be ported
161-
// to the canonical trait query form, `infcx.predicate_may_hold`, once
159+
.find(|o| !selcx.evaluate_obligation(o).may_apply());
160+
// FIXME: the call to `selcx.evaluate_obligation().may_apply` above should be
161+
// ported to the canonical trait query form, `infcx.predicate_may_hold`, once
162162
// the new system supports intercrate mode (which coherence needs).
163163

164164
if let Some(failing_obligation) = opt_failing_obligation {

src/librustc/traits/select.rs

+4-32
Original file line numberDiff line numberDiff line change
@@ -552,42 +552,14 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
552552
// The result is "true" if the obligation *may* hold and "false" if
553553
// we can be sure it does not.
554554

555-
/// Evaluates whether the obligation `obligation` can be satisfied (by any means).
555+
/// Evaluates whether the obligation `obligation` can be satisfied and returns
556+
/// an `EvaluationResult`.
556557
pub fn evaluate_obligation(&mut self,
557558
obligation: &PredicateObligation<'tcx>)
558-
-> bool
559-
{
560-
debug!("evaluate_obligation({:?})",
561-
obligation);
562-
563-
self.probe(|this, _| {
564-
this.evaluate_predicate_recursively(TraitObligationStackList::empty(), obligation)
565-
.may_apply()
566-
})
567-
}
568-
569-
/// Evaluates whether the obligation `obligation` can be satisfied,
570-
/// and returns `false` if not certain. However, this is not entirely
571-
/// accurate if inference variables are involved.
572-
pub fn evaluate_obligation_conservatively(&mut self,
573-
obligation: &PredicateObligation<'tcx>)
574-
-> bool
559+
-> EvaluationResult
575560
{
576-
debug!("evaluate_obligation_conservatively({:?})",
577-
obligation);
578-
579-
self.probe(|this, _| {
580-
this.evaluate_predicate_recursively(TraitObligationStackList::empty(), obligation)
581-
== EvaluatedToOk
582-
})
583-
}
561+
debug!("evaluate_obligation({:?})", obligation);
584562

585-
/// Evaluates whether the obligation `obligation` can be satisfied and returns
586-
/// an `EvaluationResult`.
587-
pub fn evaluate_obligation_recursively(&mut self,
588-
obligation: &PredicateObligation<'tcx>)
589-
-> EvaluationResult
590-
{
591563
self.probe(|this, _| {
592564
this.evaluate_predicate_recursively(TraitObligationStackList::empty(), obligation)
593565
})

src/librustc_traits/evaluate_obligation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ crate fn evaluate_obligation<'tcx>(
2929
let mut selcx = SelectionContext::new(&infcx);
3030
let obligation = Obligation::new(ObligationCause::dummy(), param_env, predicate);
3131

32-
selcx.evaluate_obligation_recursively(&obligation)
32+
selcx.evaluate_obligation(&obligation)
3333
})
3434
}

0 commit comments

Comments
 (0)