@@ -1104,18 +1104,29 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
11041104 * Returns true if `candidate_i` should be dropped in favor of `candidate_j`.
11051105 * This is generally true if either:
11061106 * - candidate i and candidate j are equivalent; or,
1107- * - candidate i is a where clause bound and candidate j is a concrete impl ,
1107+ * - candidate i is a conrete impl and candidate j is a where clause bound ,
11081108 * and the concrete impl is applicable to the types in the where clause bound.
11091109 *
1110- * The last case basically occurs with blanket impls like
1111- * `impl<T> Foo for T`. In that case, a bound like `T:Foo` is
1112- * kind of an "false" ambiguity -- both are applicable to any
1113- * type, but in fact coherence requires that the bound will
1114- * always be resolved to the impl anyway.
1110+ * The last case refers to cases where there are blanket impls (often conditional
1111+ * blanket impls) as well as a where clause. This can come down to one of two cases:
1112+ *
1113+ * - The impl is truly unconditional (it has no where clauses
1114+ * of its own), in which case the where clause is
1115+ * unnecessary, because coherence requires that we would
1116+ * pick that particular impl anyhow (at least so long as we
1117+ * don't have specialization).
1118+ *
1119+ * - The impl is conditional, in which case we may not have winnowed it out
1120+ * because we don't know if the conditions apply, but the where clause is basically
1121+ * telling us taht there is some impl, though not necessarily the one we see.
1122+ *
1123+ * In both cases we prefer to take the where clause, which is
1124+ * essentially harmless. See issue #18453 for more details of
1125+ * a case where doing the opposite caused us harm.
11151126 */
11161127
11171128 match ( candidate_i, candidate_j) {
1118- ( & ParamCandidate ( ref vt ) , & ImplCandidate ( impl_def_id ) ) => {
1129+ ( & ImplCandidate ( impl_def_id ) , & ParamCandidate ( ref vt ) ) => {
11191130 debug ! ( "Considering whether to drop param {} in favor of impl {}" ,
11201131 candidate_i. repr( self . tcx( ) ) ,
11211132 candidate_j. repr( self . tcx( ) ) ) ;
0 commit comments