@@ -26,7 +26,7 @@ use crate::traits::normalize::{normalize_with_depth, normalize_with_depth_to};
2626use crate :: traits:: util:: { self , closure_trait_ref_and_return_type} ;
2727use crate :: traits:: {
2828 ImplSource , ImplSourceUserDefinedData , Normalized , Obligation , ObligationCause ,
29- PolyTraitObligation , PredicateObligation , Selection , SelectionError , TraitObligation ,
29+ PolyTraitObligation , PredicateObligation , Selection , SelectionError , TraitObligation , wf ,
3030} ;
3131
3232impl < ' cx , ' tcx > SelectionContext < ' cx , ' tcx > {
@@ -587,6 +587,29 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
587587 ) ;
588588 nested. push ( obligation. with ( tcx, normalized_bound) ) ;
589589 }
590+
591+ // The above only ensures that the normalized assoc type meets the bounds.
592+ // Check well-formedness of itself as well.
593+ let normalized_assoc_type = normalize_with_depth_to (
594+ self ,
595+ obligation. param_env ,
596+ obligation. cause . clone ( ) ,
597+ obligation. recursion_depth + 1 ,
598+ Ty :: new_projection ( tcx, assoc_type, trait_predicate. trait_ref . args ) ,
599+ & mut nested,
600+ ) ;
601+ nested. extend (
602+ wf:: obligations (
603+ self . infcx ,
604+ obligation. param_env ,
605+ obligation. cause . body_id ,
606+ obligation. recursion_depth + 1 ,
607+ normalized_assoc_type. into ( ) ,
608+ obligation. cause . span ,
609+ )
610+ . into_iter ( )
611+ . flatten ( ) ,
612+ ) ;
590613 }
591614
592615 debug ! ( ?nested, "object nested obligations" ) ;
0 commit comments