@@ -503,27 +503,9 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
503503 target = self . shallow_resolve ( target) ;
504504 debug ! ( ?source, ?target) ;
505505
506- // These 'if' statements require some explanation.
507- // The `CoerceUnsized` trait is special - it is only
508- // possible to write `impl CoerceUnsized<B> for A` where
509- // A and B have 'matching' fields. This rules out the following
510- // two types of blanket impls:
511- //
512- // `impl<T> CoerceUnsized<T> for SomeType`
513- // `impl<T> CoerceUnsized<SomeType> for T`
514- //
515- // Both of these trigger a special `CoerceUnsized`-related error (E0376)
516- //
517- // We can take advantage of this fact to avoid performing unnecessary work.
518- // If either `source` or `target` is a type variable, then any applicable impl
519- // would need to be generic over the self-type (`impl<T> CoerceUnsized<SomeType> for T`)
520- // or generic over the `CoerceUnsized` type parameter (`impl<T> CoerceUnsized<T> for
521- // SomeType`).
522- //
523- // However, these are exactly the kinds of impls which are forbidden by
524- // the compiler! Therefore, we can be sure that coercion will always fail
525- // when either the source or target type is a type variable. This allows us
526- // to skip performing any trait selection, and immediately bail out.
506+ // We don't apply any coercions incase either the source or target
507+ // aren't sufficiently well known but tend to instead just equate
508+ // them both.
527509 if source. is_ty_var ( ) {
528510 debug ! ( "coerce_unsized: source is a TyVar, bailing out" ) ;
529511 return Err ( TypeError :: Mismatch ) ;
0 commit comments