@@ -1104,18 +1104,29 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1104
1104
* Returns true if `candidate_i` should be dropped in favor of `candidate_j`.
1105
1105
* This is generally true if either:
1106
1106
* - 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 ,
1108
1108
* and the concrete impl is applicable to the types in the where clause bound.
1109
1109
*
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.
1115
1126
*/
1116
1127
1117
1128
match ( candidate_i, candidate_j) {
1118
- ( & ParamCandidate ( ref vt ) , & ImplCandidate ( impl_def_id ) ) => {
1129
+ ( & ImplCandidate ( impl_def_id ) , & ParamCandidate ( ref vt ) ) => {
1119
1130
debug ! ( "Considering whether to drop param {} in favor of impl {}" ,
1120
1131
candidate_i. repr( self . tcx( ) ) ,
1121
1132
candidate_j. repr( self . tcx( ) ) ) ;
0 commit comments