Remove ErrorCandidate in favor of just generating an ambiguous result

This commit is contained in:
Niko Matsakis 2016-01-07 16:48:48 -05:00
parent b4f5ddba67
commit 64b720229c
2 changed files with 11 additions and 11 deletions

View File

@ -63,9 +63,9 @@ fn overlap<'cx, 'tcx>(selcx: &mut SelectionContext<'cx, 'tcx>,
b_def_id,
util::fresh_type_vars_for_impl);
debug!("overlap: a_trait_ref={:?}", a_trait_ref);
debug!("overlap: a_trait_ref={:?} a_obligations={:?}", a_trait_ref, a_obligations);
debug!("overlap: b_trait_ref={:?}", b_trait_ref);
debug!("overlap: b_trait_ref={:?} b_obligations={:?}", b_trait_ref, b_obligations);
// Do `a` and `b` unify? If not, no overlap.
if let Err(_) = infer::mk_eq_trait_refs(selcx.infcx(),

View File

@ -210,8 +210,6 @@ enum SelectionCandidate<'tcx> {
BuiltinObjectCandidate,
BuiltinUnsizeCandidate,
ErrorCandidate,
}
struct SelectionCandidateSet<'tcx> {
@ -753,8 +751,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
stack: &TraitObligationStack<'o, 'tcx>)
-> SelectionResult<'tcx, SelectionCandidate<'tcx>>
{
if stack.obligation.predicate.0.self_ty().references_error() {
return Ok(Some(ErrorCandidate));
if stack.obligation.predicate.references_error() {
// If we encounter a `TyError`, we generally prefer the
// most "optimistic" result in response -- that is, the
// one least likely to report downstream errors. But
// because this routine is shared by coherence and by
// trait selection, there isn't an obvious "right" choice
// here in that respect, so we opt to just return
// ambiguity and let the upstream clients sort it out.
return Ok(None);
}
if !self.is_knowable(stack) {
@ -1587,7 +1592,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
true
},
&ParamCandidate(..) => false,
&ErrorCandidate => false // propagate errors
},
_ => false
}
@ -1998,10 +2002,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
try!(self.confirm_builtin_candidate(obligation, builtin_bound))))
}
ErrorCandidate => {
Ok(VtableBuiltin(VtableBuiltinData { nested: vec![] }))
}
ParamCandidate(param) => {
let obligations = self.confirm_param_candidate(obligation, param);
Ok(VtableParam(obligations))