Skip to content

Commit 64b7202

Browse files
committed
Remove ErrorCandidate in favor of just generating an ambiguous result
1 parent b4f5ddb commit 64b7202

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/librustc/middle/traits/coherence.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ fn overlap<'cx, 'tcx>(selcx: &mut SelectionContext<'cx, 'tcx>,
6363
b_def_id,
6464
util::fresh_type_vars_for_impl);
6565

66-
debug!("overlap: a_trait_ref={:?}", a_trait_ref);
66+
debug!("overlap: a_trait_ref={:?} a_obligations={:?}", a_trait_ref, a_obligations);
6767

68-
debug!("overlap: b_trait_ref={:?}", b_trait_ref);
68+
debug!("overlap: b_trait_ref={:?} b_obligations={:?}", b_trait_ref, b_obligations);
6969

7070
// Do `a` and `b` unify? If not, no overlap.
7171
if let Err(_) = infer::mk_eq_trait_refs(selcx.infcx(),

src/librustc/middle/traits/select.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,6 @@ enum SelectionCandidate<'tcx> {
210210
BuiltinObjectCandidate,
211211

212212
BuiltinUnsizeCandidate,
213-
214-
ErrorCandidate,
215213
}
216214

217215
struct SelectionCandidateSet<'tcx> {
@@ -753,8 +751,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
753751
stack: &TraitObligationStack<'o, 'tcx>)
754752
-> SelectionResult<'tcx, SelectionCandidate<'tcx>>
755753
{
756-
if stack.obligation.predicate.0.self_ty().references_error() {
757-
return Ok(Some(ErrorCandidate));
754+
if stack.obligation.predicate.references_error() {
755+
// If we encounter a `TyError`, we generally prefer the
756+
// most "optimistic" result in response -- that is, the
757+
// one least likely to report downstream errors. But
758+
// because this routine is shared by coherence and by
759+
// trait selection, there isn't an obvious "right" choice
760+
// here in that respect, so we opt to just return
761+
// ambiguity and let the upstream clients sort it out.
762+
return Ok(None);
758763
}
759764

760765
if !self.is_knowable(stack) {
@@ -1587,7 +1592,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
15871592
true
15881593
},
15891594
&ParamCandidate(..) => false,
1590-
&ErrorCandidate => false // propagate errors
15911595
},
15921596
_ => false
15931597
}
@@ -1998,10 +2002,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
19982002
try!(self.confirm_builtin_candidate(obligation, builtin_bound))))
19992003
}
20002004

2001-
ErrorCandidate => {
2002-
Ok(VtableBuiltin(VtableBuiltinData { nested: vec![] }))
2003-
}
2004-
20052005
ParamCandidate(param) => {
20062006
let obligations = self.confirm_param_candidate(obligation, param);
20072007
Ok(VtableParam(obligations))

0 commit comments

Comments
 (0)