Simplify trait selector's evaluation API slightly

This commit is contained in:
Aravind Gollakota 2018-04-08 02:04:46 -05:00
parent bc16b8e92a
commit 3dd26b8a3e
2 changed files with 6 additions and 22 deletions

View File

@ -154,8 +154,8 @@ fn overlap<'cx, 'gcx, 'tcx>(selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>,
recursion_depth: 0,
predicate: p })
.chain(obligations)
.find(|o| !selcx.evaluate_obligation(o));
// FIXME: the call to `selcx.evaluate_obligation` above should be ported
.find(|o| !selcx.predicate_may_hold_fatal(o));
// FIXME: the call to `selcx.predicate_may_hold_fatal` above should be ported
// to the canonical trait query form, `infcx.predicate_may_hold`, once
// the new system supports intercrate mode (which coherence needs).

View File

@ -575,11 +575,11 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
// we can be sure it does not.
/// Evaluates whether the obligation `obligation` can be satisfied (by any means).
pub fn evaluate_obligation(&mut self,
obligation: &PredicateObligation<'tcx>)
-> bool
pub fn predicate_may_hold_fatal(&mut self,
obligation: &PredicateObligation<'tcx>)
-> bool
{
debug!("evaluate_obligation({:?})",
debug!("predicate_may_hold_fatal({:?})",
obligation);
match self.evaluate_obligation_recursively(obligation) {
@ -588,22 +588,6 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
}
}
/// Evaluates whether the obligation `obligation` can be satisfied,
/// and returns `false` if not certain. However, this is not entirely
/// accurate if inference variables are involved.
pub fn evaluate_obligation_conservatively(&mut self,
obligation: &PredicateObligation<'tcx>)
-> bool
{
debug!("evaluate_obligation_conservatively({:?})",
obligation);
match self.evaluate_obligation_recursively(obligation) {
Ok(result) => result == EvaluatedToOk,
Err(OverflowError(o)) => self.infcx().report_overflow_error(&o, true)
}
}
/// Evaluates whether the obligation `obligation` can be satisfied and returns
/// an `EvaluationResult`.
pub fn evaluate_obligation_recursively(&mut self,