EvaluatedToErr
});
-#[derive(Clone, Debug, PartialEq, Eq)]
-/// Indicates that trait evaluation caused overflow. Stores the obligation
-/// that hit the recursion limit.
-pub struct OverflowError<'tcx>(pub TraitObligation<'tcx>);
+#[derive(Copy, Clone, Debug, PartialEq, Eq)]
+/// Indicates that trait evaluation caused overflow.
+pub struct OverflowError;
-impl<'tcx> From<OverflowError<'tcx>> for SelectionError<'tcx> {
- fn from(OverflowError(o): OverflowError<'tcx>) -> SelectionError<'tcx> {
- SelectionError::Overflow(o)
+impl<'tcx> From<OverflowError> for SelectionError<'tcx> {
+ fn from(OverflowError: OverflowError) -> SelectionError<'tcx> {
+ SelectionError::Overflow
}
}
assert!(self.query_mode == TraitQueryMode::Standard);
let candidate = match self.candidate_from_obligation(&stack) {
- Err(SelectionError::Overflow(_)) =>
+ Err(SelectionError::Overflow) =>
bug!("Overflow should be caught earlier in standard query mode"),
Err(e) => { return Err(e); },
Ok(None) => { return Ok(None); },
};
match self.confirm_candidate(obligation, candidate) {
- Err(SelectionError::Overflow(_)) =>
+ Err(SelectionError::Overflow) =>
bug!("Overflow should be caught earlier in standard query mode"),
Err(e) => Err(e),
Ok(candidate) => Ok(Some(candidate))
/// an `EvaluationResult`.
pub fn evaluate_obligation_recursively(&mut self,
obligation: &PredicateObligation<'tcx>)
- -> Result<EvaluationResult, OverflowError<'tcx>>
+ -> Result<EvaluationResult, OverflowError>
{
self.probe(|this, _| {
this.evaluate_predicate_recursively(TraitObligationStackList::empty(), obligation)
fn evaluate_predicates_recursively<'a,'o,I>(&mut self,
stack: TraitObligationStackList<'o, 'tcx>,
predicates: I)
- -> Result<EvaluationResult, OverflowError<'tcx>>
+ -> Result<EvaluationResult, OverflowError>
where I : IntoIterator<Item=&'a PredicateObligation<'tcx>>, 'tcx:'a
{
let mut result = EvaluatedToOk;
fn evaluate_predicate_recursively<'o>(&mut self,
previous_stack: TraitObligationStackList<'o, 'tcx>,
obligation: &PredicateObligation<'tcx>)
- -> Result<EvaluationResult, OverflowError<'tcx>>
+ -> Result<EvaluationResult, OverflowError>
{
debug!("evaluate_predicate_recursively({:?})",
obligation);
fn evaluate_trait_predicate_recursively<'o>(&mut self,
previous_stack: TraitObligationStackList<'o, 'tcx>,
mut obligation: TraitObligation<'tcx>)
- -> Result<EvaluationResult, OverflowError<'tcx>>
+ -> Result<EvaluationResult, OverflowError>
{
debug!("evaluate_trait_predicate_recursively({:?})",
obligation);
fn evaluate_stack<'o>(&mut self,
stack: &TraitObligationStack<'o, 'tcx>)
- -> Result<EvaluationResult, OverflowError<'tcx>>
+ -> Result<EvaluationResult, OverflowError>
{
// In intercrate mode, whenever any of the types are unbound,
// there can always be an impl. Even if there are no impls in
match self.candidate_from_obligation(stack) {
Ok(Some(c)) => self.evaluate_candidate(stack, &c),
Ok(None) => Ok(EvaluatedToAmbig),
- Err(Overflow(o)) => Err(OverflowError(o)),
+ Err(Overflow) => Err(OverflowError),
Err(..) => Ok(EvaluatedToErr)
}
}
fn evaluate_candidate<'o>(&mut self,
stack: &TraitObligationStack<'o, 'tcx>,
candidate: &SelectionCandidate<'tcx>)
- -> Result<EvaluationResult, OverflowError<'tcx>>
+ -> Result<EvaluationResult, OverflowError>
{
debug!("evaluate_candidate: depth={} candidate={:?}",
stack.obligation.recursion_depth, candidate);
self.infcx().report_overflow_error(&stack.obligation, true);
},
TraitQueryMode::Canonical => {
- return Err(Overflow(stack.obligation.clone()));
+ return Err(Overflow);
},
}
}
.vec
.iter()
.map(|c| self.evaluate_candidate(stack, &c))
- .collect::<Result<Vec<_>, OverflowError<'_>>>()?
+ .collect::<Result<Vec<_>, OverflowError>>()?
.iter()
.all(|r| !r.may_apply());
if !candidate_set.ambiguous && no_candidates_apply {
evaluation: eval,
})),
Ok(_) => Ok(None),
- Err(OverflowError(o)) => Err(Overflow(o)),
+ Err(OverflowError) => Err(Overflow),
})
.collect();
fn evaluate_where_clause<'o>(&mut self,
stack: &TraitObligationStack<'o, 'tcx>,
where_clause_trait_ref: ty::PolyTraitRef<'tcx>)
- -> Result<EvaluationResult, OverflowError<'tcx>>
+ -> Result<EvaluationResult, OverflowError>
{
self.probe(move |this, _| {
match this.match_where_clause_trait_ref(stack.obligation, where_clause_trait_ref) {