@@ -452,9 +452,13 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
452
452
// &[T; n] or &mut [T; n] -> &[T]
453
453
// or &mut [T; n] -> &mut [T]
454
454
// 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 > {
456
456
debug ! ( "coerce_unsized(source={:?}, target={:?})" , source, target) ;
457
457
458
+ source = self . shallow_resolve ( source) ;
459
+ target = self . shallow_resolve ( target) ;
460
+ debug ! ( "coerce_unsized: resolved source={:?} target={:?}" , source, target) ;
461
+
458
462
// These 'if' statements require some explanation.
459
463
// The `CoerceUnsized` trait is special - it is only
460
464
// possible to write `impl CoerceUnsized<B> for A` where
@@ -476,11 +480,11 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
476
480
// the compiler! Therefore, we can be sure that coercion will always fail
477
481
// when either the source or target type is a type variable. This allows us
478
482
// 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 ( ) {
480
484
debug ! ( "coerce_unsized: source is a TyVar, bailing out" ) ;
481
485
return Err ( TypeError :: Mismatch ) ;
482
486
}
483
- if self . shallow_resolve ( target) . is_ty_var ( ) {
487
+ if target. is_ty_var ( ) {
484
488
debug ! ( "coerce_unsized: target is a TyVar, bailing out" ) ;
485
489
return Err ( TypeError :: Mismatch ) ;
486
490
}
0 commit comments