fn candidate_should_be_dropped_in_favor_of<'o>(&mut self,
                                                   stack: &ObligationStack<'o, 'tcx>,
                                                   candidate_i: &Candidate<'tcx>,
                                                   candidate_j: &Candidate<'tcx>)
                                                   -> bool
    {
        match (candidate_i, candidate_j) {
            (&ImplCandidate(impl_def_id), &ParamCandidate(ref vt)) => {
                debug!("Considering whether to drop param {} in favor of impl {}",
                       candidate_i.repr(self.tcx()),
                       candidate_j.repr(self.tcx()));

                self.infcx.probe(|| {
                    let impl_substs =
                        self.rematch_impl(impl_def_id, stack.obligation);
                    let impl_trait_ref =
                        ty::impl_trait_ref(self.tcx(), impl_def_id).unwrap();
                    let impl_trait_ref =
                        impl_trait_ref.subst(self.tcx(), &impl_substs);
                    let origin =
                        infer::RelateOutputImplTypes(stack.obligation.cause.span);
                    self.infcx
                        .sub_trait_refs(false, origin,
                                        impl_trait_ref, vt.bound.clone())
                        .is_ok()
                })
            }
            _ => {
                *candidate_i == *candidate_j
            }
        }
    }
/// Returns true if `candidate_i` should be dropped in favor of `candidate_j`.
///
/// This is generally true if either:
/// - candidate i and candidate j are equivalent; or,
/// - candidate i is a conrete impl and candidate j is a where clause bound,
///   and the concrete impl is applicable to the types in the where clause bound.
///
/// The last case refers to cases where there are blanket impls (often conditional
/// blanket impls) as well as a where clause. This can come down to one of two cases:
///
/// - The impl is truly unconditional (it has no where clauses
///   of its own), in which case the where clause is
///   unnecessary, because coherence requires that we would
///   pick that particular impl anyhow (at least so long as we
///   don't have specialization).
///
/// - The impl is conditional, in which case we may not have winnowed it out
///   because we don't know if the conditions apply, but the where clause is basically
///   telling us taht there is some impl, though not necessarily the one we see.
///
/// In both cases we prefer to take the where clause, which is
/// essentially harmless.  See issue #18453 for more details of
/// a case where doing the opposite caused us harm.
Returns true if `candidate_i` should be dropped in favor of `candidate_j`.
This is generally true if either:
candidate i and candidate j are equivalent; or,
candidate i is a conrete impl and candidate j is a where clause bound,
and the concrete impl is applicable to the types in the where clause bound.

The last case refers to cases where there are blanket impls (often conditional
blanket impls) as well as a where clause. This can come down to one of two cases.

The impl is truly unconditional (it has no where clauses
of its own), in which case the where clause is
unnecessary, because coherence requires that we would
pick that particular impl anyhow (at least so long as we
don't have specialization).

The impl is conditional, in which case we may not have winnowed it out
because we don't know if the conditions apply, but the where clause is basically
telling us taht there is some impl, though not necessarily the one we see.

In both cases we prefer to take the where clause, which is
essentially harmless.  See issue #18453 for more details of
a case where doing the opposite caused us harm.
Returns true if ` candidate_i ` should be dropped in favor of ` candidate_j ` . This is generally true if either : candidate i and candidate j are equivalent ; or candidate i is a conrete impl and candidate j is a where clause bound and the concrete impl is applicable to the types in the where clause bound . The last case refers to cases where there are blanket impls ( often conditional blanket impls ) as well as a where clause . This can come down to one of two cases . The impl is truly unconditional ( it has no where clauses of its own ) in which case the where clause is unnecessary because coherence requires that we would pick that particular impl anyhow ( at least so long as we don ' t have specialization ) . The impl is conditional in which case we may not have winnowed it out because we don ' t know if the conditions apply but the where clause is basically telling us taht there is some impl though not necessarily the one we see . In both cases we prefer to take the where clause which is essentially harmless . See issue #18453 for more details of a case where doing the opposite caused us harm .
fn candidate_should_be_dropped_in_favor_of<'o>(&mut self,
                                                   stack: &ObligationStack<'o, 'tcx>,
                                                   candidate_i: &Candidate<'tcx>,
                                                   candidate_j: &Candidate<'tcx>)
                                                   -> bool
    {
        match (candidate_i, candidate_j) {
            (&ImplCandidate(impl_def_id), &ParamCandidate(ref vt)) => {
                debug!("Considering whether to drop param {} in favor of impl {}",
                       candidate_i.repr(self.tcx()),
                       candidate_j.repr(self.tcx()));
                self.infcx.probe(|| {
                    let impl_substs =
                        self.rematch_impl(impl_def_id, stack.obligation);
                    let impl_trait_ref =
                        ty::impl_trait_ref(self.tcx(), impl_def_id).unwrap();
                    let impl_trait_ref =
                        impl_trait_ref.subst(self.tcx(), &impl_substs);
                    let origin =
                        infer::RelateOutputImplTypes(stack.obligation.cause.span);
                    self.infcx
                        .sub_trait_refs(false, origin,
                                        impl_trait_ref, vt.bound.clone())
                        .is_ok()
                })
            }
            _ => {
                *candidate_i == *candidate_j
            }
        }
    }
fn candidate_should_be_dropped_in_favor_of < ' o > ( & mut self , stack : & ObligationStack < ' o , ' tcx > , candidate_i : & Candidate < ' tcx > , candidate_j : & Candidate < ' tcx > ) -> bool { match ( candidate_i , candidate_j ) { ( & ImplCandidate ( impl_def_id ) , & ParamCandidate ( ref vt ) ) => { debug ! ( " " candidate_i repr ( self tcx ( ) ) candidate_j repr ( self tcx ( ) ) ) ; self . infcx . probe ( | | { let impl_substs = self . rematch_impl ( impl_def_id , stack . obligation ) ; let impl_trait_ref = ty :: impl_trait_ref ( self . tcx ( ) , impl_def_id ) . unwrap ( ) ; let impl_trait_ref = impl_trait_ref . subst ( self . tcx ( ) , & impl_substs ) ; let origin = infer :: RelateOutputImplTypes ( stack . obligation . cause . span ) ; self . infcx . sub_trait_refs ( false , origin , impl_trait_ref , vt . bound . clone ( ) ) . is_ok ( ) } ) } _ => { * candidate_i == * candidate_j } } }
Returns true if `candidate_i` should be dropped in favor of `candidate_j`.
Returns true if ` candidate_i ` should be dropped in favor of ` candidate_j ` .
&mut self
stack
&ObligationStack<'o, 'tcx>
candidate_i
&Candidate<'tcx>
candidate_j
&Candidate<'tcx>