@@ -580,24 +580,24 @@ pub(super) fn explicit_predicates_of<'tcx>(
580
580
/// Ensures that the super-predicates of the trait with a `DefId`
581
581
/// of `trait_def_id` are lowered and stored. This also ensures that
582
582
/// the transitive super-predicates are lowered.
583
- pub ( super ) fn explicit_super_predicates_of (
584
- tcx : TyCtxt < ' _ > ,
583
+ pub ( super ) fn explicit_super_predicates_of < ' tcx > (
584
+ tcx : TyCtxt < ' tcx > ,
585
585
trait_def_id : LocalDefId ,
586
- ) -> ty:: GenericPredicates < ' _ > {
586
+ ) -> ty:: EarlyBinder < ' tcx , & ' tcx [ ( ty :: Clause < ' tcx > , Span ) ] > {
587
587
implied_predicates_with_filter ( tcx, trait_def_id. to_def_id ( ) , PredicateFilter :: SelfOnly )
588
588
}
589
589
590
- pub ( super ) fn explicit_supertraits_containing_assoc_item (
591
- tcx : TyCtxt < ' _ > ,
590
+ pub ( super ) fn explicit_supertraits_containing_assoc_item < ' tcx > (
591
+ tcx : TyCtxt < ' tcx > ,
592
592
( trait_def_id, assoc_name) : ( DefId , Ident ) ,
593
- ) -> ty:: GenericPredicates < ' _ > {
593
+ ) -> ty:: EarlyBinder < ' tcx , & ' tcx [ ( ty :: Clause < ' tcx > , Span ) ] > {
594
594
implied_predicates_with_filter ( tcx, trait_def_id, PredicateFilter :: SelfThatDefines ( assoc_name) )
595
595
}
596
596
597
- pub ( super ) fn explicit_implied_predicates_of (
598
- tcx : TyCtxt < ' _ > ,
597
+ pub ( super ) fn explicit_implied_predicates_of < ' tcx > (
598
+ tcx : TyCtxt < ' tcx > ,
599
599
trait_def_id : LocalDefId ,
600
- ) -> ty:: GenericPredicates < ' _ > {
600
+ ) -> ty:: EarlyBinder < ' tcx , & ' tcx [ ( ty :: Clause < ' tcx > , Span ) ] > {
601
601
implied_predicates_with_filter (
602
602
tcx,
603
603
trait_def_id. to_def_id ( ) ,
@@ -612,11 +612,11 @@ pub(super) fn explicit_implied_predicates_of(
612
612
/// Ensures that the super-predicates of the trait with a `DefId`
613
613
/// of `trait_def_id` are lowered and stored. This also ensures that
614
614
/// the transitive super-predicates are lowered.
615
- pub ( super ) fn implied_predicates_with_filter (
616
- tcx : TyCtxt < ' _ > ,
615
+ pub ( super ) fn implied_predicates_with_filter < ' tcx > (
616
+ tcx : TyCtxt < ' tcx > ,
617
617
trait_def_id : DefId ,
618
618
filter : PredicateFilter ,
619
- ) -> ty:: GenericPredicates < ' _ > {
619
+ ) -> ty:: EarlyBinder < ' tcx , & ' tcx [ ( ty :: Clause < ' tcx > , Span ) ] > {
620
620
let Some ( trait_def_id) = trait_def_id. as_local ( ) else {
621
621
// if `assoc_name` is None, then the query should've been redirected to an
622
622
// external provider
@@ -679,20 +679,16 @@ pub(super) fn implied_predicates_with_filter(
679
679
_ => { }
680
680
}
681
681
682
- ty:: GenericPredicates {
683
- parent : None ,
684
- predicates : implied_bounds,
685
- effects_min_tys : ty:: List :: empty ( ) ,
686
- }
682
+ ty:: EarlyBinder :: bind ( implied_bounds)
687
683
}
688
684
689
685
/// Returns the predicates defined on `item_def_id` of the form
690
686
/// `X: Foo` where `X` is the type parameter `def_id`.
691
687
#[ instrument( level = "trace" , skip( tcx) ) ]
692
- pub ( super ) fn type_param_predicates (
693
- tcx : TyCtxt < ' _ > ,
688
+ pub ( super ) fn type_param_predicates < ' tcx > (
689
+ tcx : TyCtxt < ' tcx > ,
694
690
( item_def_id, def_id, assoc_name) : ( LocalDefId , LocalDefId , Ident ) ,
695
- ) -> ty:: GenericPredicates < ' _ > {
691
+ ) -> ty:: EarlyBinder < ' tcx , & ' tcx [ ( ty :: Clause < ' tcx > , Span ) ] > {
696
692
use rustc_hir:: * ;
697
693
use rustc_middle:: ty:: Ty ;
698
694
@@ -713,18 +709,20 @@ pub(super) fn type_param_predicates(
713
709
tcx. generics_of ( item_def_id) . parent . map ( |def_id| def_id. expect_local ( ) )
714
710
} ;
715
711
716
- let mut result = parent
717
- . map ( |parent| {
718
- let icx = ItemCtxt :: new ( tcx , parent ) ;
719
- icx . probe_ty_param_bounds ( DUMMY_SP , def_id , assoc_name )
720
- } )
721
- . unwrap_or_default ( ) ;
712
+ let result = if let Some ( parent) = parent {
713
+ let icx = ItemCtxt :: new ( tcx , parent ) ;
714
+ icx. probe_ty_param_bounds ( DUMMY_SP , def_id , assoc_name )
715
+ } else {
716
+ ty :: EarlyBinder :: bind ( & [ ] as & [ _ ] )
717
+ } ;
722
718
let mut extend = None ;
723
719
724
720
let item_hir_id = tcx. local_def_id_to_hir_id ( item_def_id) ;
725
721
726
722
let hir_node = tcx. hir_node ( item_hir_id) ;
727
- let Some ( hir_generics) = hir_node. generics ( ) else { return result } ;
723
+ let Some ( hir_generics) = hir_node. generics ( ) else {
724
+ return result;
725
+ } ;
728
726
if let Node :: Item ( item) = hir_node
729
727
&& let ItemKind :: Trait ( ..) = item. kind
730
728
// Implied `Self: Trait` and supertrait bounds.
@@ -748,9 +746,10 @@ pub(super) fn type_param_predicates(
748
746
_ => false ,
749
747
} ) ,
750
748
) ;
751
- result. predicates =
752
- tcx. arena . alloc_from_iter ( result. predicates . iter ( ) . copied ( ) . chain ( extra_predicates) ) ;
753
- result
749
+
750
+ ty:: EarlyBinder :: bind (
751
+ tcx. arena . alloc_from_iter ( result. skip_binder ( ) . iter ( ) . copied ( ) . chain ( extra_predicates) ) ,
752
+ )
754
753
}
755
754
756
755
impl < ' tcx > ItemCtxt < ' tcx > {
0 commit comments