@@ -452,9 +452,13 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
452452 // &[T; n] or &mut [T; n] -> &[T]
453453 // or &mut [T; n] -> &mut [T]
454454 // or &Concrete -> &Trait, etc.
455- fn coerce_unsized ( & self , source : Ty < ' tcx > , target : Ty < ' tcx > ) -> CoerceResult < ' tcx > {
455+ fn coerce_unsized ( & self , mut source : Ty < ' tcx > , mut target : Ty < ' tcx > ) -> CoerceResult < ' tcx > {
456456 debug ! ( "coerce_unsized(source={:?}, target={:?})" , source, target) ;
457457
458+ source = self . shallow_resolve ( source) ;
459+ target = self . shallow_resolve ( target) ;
460+ debug ! ( "coerce_unsized: resolved source={:?} target={:?}" , source, target) ;
461+
458462 // These 'if' statements require some explanation.
459463 // The `CoerceUnsized` trait is special - it is only
460464 // possible to write `impl CoerceUnsized<B> for A` where
@@ -476,11 +480,11 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
476480 // the compiler! Therefore, we can be sure that coercion will always fail
477481 // when either the source or target type is a type variable. This allows us
478482 // to skip performing any trait selection, and immediately bail out.
479- if self . shallow_resolve ( source) . is_ty_var ( ) {
483+ if source. is_ty_var ( ) {
480484 debug ! ( "coerce_unsized: source is a TyVar, bailing out" ) ;
481485 return Err ( TypeError :: Mismatch ) ;
482486 }
483- if self . shallow_resolve ( target) . is_ty_var ( ) {
487+ if target. is_ty_var ( ) {
484488 debug ! ( "coerce_unsized: target is a TyVar, bailing out" ) ;
485489 return Err ( TypeError :: Mismatch ) ;
486490 }
0 commit comments