diff --git a/src/librustc/middle/traits/coherence.rs b/src/librustc/middle/traits/coherence.rs index 62a769fbff8..0f95aa74b6f 100644 --- a/src/librustc/middle/traits/coherence.rs +++ b/src/librustc/middle/traits/coherence.rs @@ -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(), diff --git a/src/librustc/middle/traits/select.rs b/src/librustc/middle/traits/select.rs index f544f8ce362..f6d0da904a4 100644 --- a/src/librustc/middle/traits/select.rs +++ b/src/librustc/middle/traits/select.rs @@ -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))