@@ -564,7 +564,11 @@ pub(super) fn explicit_supertraits_containing_assoc_item<'tcx>(
564564 tcx : TyCtxt < ' tcx > ,
565565 ( trait_def_id, assoc_name) : ( DefId , Ident ) ,
566566) -> ty:: EarlyBinder < ' tcx , & ' tcx [ ( ty:: Clause < ' tcx > , Span ) ] > {
567- implied_predicates_with_filter ( tcx, trait_def_id, PredicateFilter :: SelfThatDefines ( assoc_name) )
567+ implied_predicates_with_filter (
568+ tcx,
569+ trait_def_id,
570+ PredicateFilter :: SelfTraitThatDefines ( assoc_name) ,
571+ )
568572}
569573
570574pub ( super ) fn explicit_implied_predicates_of < ' tcx > (
@@ -593,7 +597,7 @@ pub(super) fn implied_predicates_with_filter<'tcx>(
593597 let Some ( trait_def_id) = trait_def_id. as_local ( ) else {
594598 // if `assoc_name` is None, then the query should've been redirected to an
595599 // external provider
596- assert_matches ! ( filter, PredicateFilter :: SelfThatDefines ( _) ) ;
600+ assert_matches ! ( filter, PredicateFilter :: SelfTraitThatDefines ( _) ) ;
597601 return tcx. explicit_super_predicates_of ( trait_def_id) ;
598602 } ;
599603
@@ -667,7 +671,7 @@ pub(super) fn assert_only_contains_predicates_from<'tcx>(
667671 }
668672
669673 match filter {
670- PredicateFilter :: SelfOnly | PredicateFilter :: SelfThatDefines ( _ ) => {
674+ PredicateFilter :: SelfOnly => {
671675 for ( clause, _) in bounds {
672676 match clause. kind ( ) . skip_binder ( ) {
673677 ty:: ClauseKind :: Trait ( trait_predicate) => {
@@ -707,6 +711,33 @@ pub(super) fn assert_only_contains_predicates_from<'tcx>(
707711 }
708712 }
709713 }
714+ PredicateFilter :: SelfTraitThatDefines ( _) => {
715+ for ( clause, _) in bounds {
716+ match clause. kind ( ) . skip_binder ( ) {
717+ ty:: ClauseKind :: Trait ( trait_predicate) => {
718+ assert_eq ! (
719+ trait_predicate. self_ty( ) ,
720+ ty,
721+ "expected `Self` predicate when computing \
722+ `{filter:?}` implied bounds: {clause:?}"
723+ ) ;
724+ }
725+
726+ ty:: ClauseKind :: Projection ( _)
727+ | ty:: ClauseKind :: TypeOutlives ( _)
728+ | ty:: ClauseKind :: RegionOutlives ( _)
729+ | ty:: ClauseKind :: ConstArgHasType ( _, _)
730+ | ty:: ClauseKind :: WellFormed ( _)
731+ | ty:: ClauseKind :: ConstEvaluatable ( _)
732+ | ty:: ClauseKind :: HostEffect ( ..) => {
733+ bug ! (
734+ "unexpected non-`Self` predicate when computing \
735+ `{filter:?}` implied bounds: {clause:?}"
736+ ) ;
737+ }
738+ }
739+ }
740+ }
710741 PredicateFilter :: ConstIfConst => {
711742 for ( clause, _) in bounds {
712743 match clause. kind ( ) . skip_binder ( ) {
@@ -768,11 +799,10 @@ pub(super) fn type_param_predicates<'tcx>(
768799
769800 let param_id = tcx. local_def_id_to_hir_id ( def_id) ;
770801 let param_owner = tcx. hir ( ) . ty_param_owner ( def_id) ;
771- let generics = tcx. generics_of ( param_owner) ;
772- let index = generics. param_def_id_to_index [ & def_id. to_def_id ( ) ] ;
773802
774803 // Don't look for bounds where the type parameter isn't in scope.
775804 let parent = if item_def_id == param_owner {
805+ // FIXME: Shouldn't this be unreachable?
776806 None
777807 } else {
778808 tcx. generics_of ( item_def_id) . parent . map ( |def_id| def_id. expect_local ( ) )
@@ -792,6 +822,7 @@ pub(super) fn type_param_predicates<'tcx>(
792822 let Some ( hir_generics) = hir_node. generics ( ) else {
793823 return result;
794824 } ;
825+
795826 if let Node :: Item ( item) = hir_node
796827 && let ItemKind :: Trait ( ..) = item. kind
797828 // Implied `Self: Trait` and supertrait bounds.
@@ -802,18 +833,11 @@ pub(super) fn type_param_predicates<'tcx>(
802833 }
803834
804835 let icx = ItemCtxt :: new ( tcx, item_def_id) ;
805- let extra_predicates = extend. into_iter ( ) . chain (
806- icx. probe_ty_param_bounds_in_generics (
807- hir_generics,
808- def_id,
809- PredicateFilter :: SelfThatDefines ( assoc_name) ,
810- )
811- . into_iter ( )
812- . filter ( |( predicate, _) | match predicate. kind ( ) . skip_binder ( ) {
813- ty:: ClauseKind :: Trait ( data) => data. self_ty ( ) . is_param ( index) ,
814- _ => false ,
815- } ) ,
816- ) ;
836+ let extra_predicates = extend. into_iter ( ) . chain ( icx. probe_ty_param_bounds_in_generics (
837+ hir_generics,
838+ def_id,
839+ PredicateFilter :: SelfTraitThatDefines ( assoc_name) ,
840+ ) ) ;
817841
818842 ty:: EarlyBinder :: bind (
819843 tcx. arena . alloc_from_iter ( result. skip_binder ( ) . iter ( ) . copied ( ) . chain ( extra_predicates) ) ,
@@ -848,7 +872,7 @@ impl<'tcx> ItemCtxt<'tcx> {
848872 // Ok
849873 }
850874 PredicateFilter :: SelfOnly
851- | PredicateFilter :: SelfThatDefines ( _)
875+ | PredicateFilter :: SelfTraitThatDefines ( _)
852876 | PredicateFilter :: SelfConstIfConst
853877 | PredicateFilter :: SelfAndAssociatedTypeBounds => continue ,
854878 PredicateFilter :: ConstIfConst => unreachable ! ( ) ,
0 commit comments