@@ -622,7 +622,6 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
622
622
ty:: TraitRef :: new( self . tcx, coerce_unsized_did, [ coerce_source, coerce_target] )
623
623
) ] ;
624
624
625
- let mut has_unsized_tuple_coercion = false ;
626
625
let mut has_trait_upcasting_coercion = None ;
627
626
628
627
// Keep resolving `CoerceUnsized` and `Unsize` predicates to avoid
@@ -636,29 +635,14 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
636
635
Some ( ty:: PredicateKind :: Clause ( ty:: ClauseKind :: Trait ( trait_pred) ) )
637
636
if traits. contains ( & trait_pred. def_id ( ) ) =>
638
637
{
639
- let trait_pred = self . resolve_vars_if_possible ( trait_pred) ;
640
- if unsize_did == trait_pred. def_id ( ) {
641
- let self_ty = trait_pred. self_ty ( ) ;
642
- let unsize_ty = trait_pred. trait_ref . args [ 1 ] . expect_ty ( ) ;
643
- if let ( ty:: Dynamic ( ref data_a, ..) , ty:: Dynamic ( ref data_b, ..) ) =
644
- ( self_ty. kind ( ) , unsize_ty. kind ( ) )
645
- && data_a. principal_def_id ( ) != data_b. principal_def_id ( )
646
- {
647
- debug ! ( "coerce_unsized: found trait upcasting coercion" ) ;
648
- has_trait_upcasting_coercion = Some ( ( self_ty, unsize_ty) ) ;
649
- }
650
- if let ty:: Tuple ( ..) = unsize_ty. kind ( ) {
651
- debug ! ( "coerce_unsized: found unsized tuple coercion" ) ;
652
- has_unsized_tuple_coercion = true ;
653
- }
654
- }
655
638
trait_pred
656
639
}
657
640
_ => {
658
641
coercion. obligations . push ( obligation) ;
659
642
continue ;
660
643
}
661
644
} ;
645
+ let trait_pred = self . resolve_vars_if_possible ( trait_pred) ;
662
646
match selcx. select ( & obligation. with ( selcx. tcx ( ) , trait_pred) ) {
663
647
// Uncertain or unimplemented.
664
648
Ok ( None ) => {
@@ -701,18 +685,15 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
701
685
// be silent, as it causes a type mismatch later.
702
686
}
703
687
704
- Ok ( Some ( impl_source) ) => queue. extend ( impl_source. nested_obligations ( ) ) ,
705
- }
706
- }
688
+ Ok ( Some ( impl_source) ) => {
689
+ if matches ! ( impl_source, traits:: ImplSource :: TraitUpcasting ( ..) ) {
690
+ has_trait_upcasting_coercion =
691
+ Some ( ( trait_pred. self_ty ( ) , trait_pred. trait_ref . args . type_at ( 1 ) ) ) ;
692
+ }
707
693
708
- if has_unsized_tuple_coercion && !self . tcx . features ( ) . unsized_tuple_coercion {
709
- feature_err (
710
- & self . tcx . sess . parse_sess ,
711
- sym:: unsized_tuple_coercion,
712
- self . cause . span ,
713
- "unsized tuple coercion is not stable enough for use and is subject to change" ,
714
- )
715
- . emit ( ) ;
694
+ queue. extend ( impl_source. nested_obligations ( ) )
695
+ }
696
+ }
716
697
}
717
698
718
699
if let Some ( ( sub, sup) ) = has_trait_upcasting_coercion
0 commit comments