@@ -20,7 +20,7 @@ fn associated_type_bounds<'tcx>(
2020 assoc_item_def_id : LocalDefId ,
2121 ast_bounds : & ' tcx [ hir:: GenericBound < ' tcx > ] ,
2222 span : Span ,
23- ) -> & ' tcx [ ( ty:: Predicate < ' tcx > , Span ) ] {
23+ ) -> & ' tcx [ ( ty:: Clause < ' tcx > , Span ) ] {
2424 let item_ty = tcx. mk_projection (
2525 assoc_item_def_id. to_def_id ( ) ,
2626 InternalSubsts :: identity_for_item ( tcx, assoc_item_def_id) ,
@@ -34,8 +34,11 @@ fn associated_type_bounds<'tcx>(
3434 let trait_def_id = tcx. local_parent ( assoc_item_def_id) ;
3535 let trait_predicates = tcx. trait_explicit_predicates_and_bounds ( trait_def_id) ;
3636
37- let bounds_from_parent = trait_predicates. predicates . iter ( ) . copied ( ) . filter ( |( pred, _) | {
38- match pred. kind ( ) . skip_binder ( ) {
37+ let bounds_from_parent = trait_predicates
38+ . predicates
39+ . iter ( )
40+ . copied ( )
41+ . filter ( |( pred, _) | match pred. kind ( ) . skip_binder ( ) {
3942 ty:: PredicateKind :: Clause ( ty:: ClauseKind :: Trait ( tr) ) => tr. self_ty ( ) == item_ty,
4043 ty:: PredicateKind :: Clause ( ty:: ClauseKind :: Projection ( proj) ) => {
4144 proj. projection_ty . self_ty ( ) == item_ty
@@ -44,15 +47,10 @@ fn associated_type_bounds<'tcx>(
4447 outlives. 0 == item_ty
4548 }
4649 _ => false ,
47- }
48- } ) ;
50+ } )
51+ . map ( | ( pred , span ) | ( pred . as_clause ( ) . unwrap ( ) , span ) ) ;
4952
50- let all_bounds = tcx. arena . alloc_from_iter (
51- bounds
52- . predicates ( )
53- . map ( |( clause, span) | ( clause. to_predicate ( tcx) , span) )
54- . chain ( bounds_from_parent) ,
55- ) ;
53+ let all_bounds = tcx. arena . alloc_from_iter ( bounds. clauses ( ) . chain ( bounds_from_parent) ) ;
5654 debug ! (
5755 "associated_type_bounds({}) = {:?}" ,
5856 tcx. def_path_str( assoc_item_def_id. to_def_id( ) ) ,
@@ -72,24 +70,22 @@ fn opaque_type_bounds<'tcx>(
7270 ast_bounds : & ' tcx [ hir:: GenericBound < ' tcx > ] ,
7371 item_ty : Ty < ' tcx > ,
7472 span : Span ,
75- ) -> & ' tcx [ ( ty:: Predicate < ' tcx > , Span ) ] {
73+ ) -> & ' tcx [ ( ty:: Clause < ' tcx > , Span ) ] {
7674 ty:: print:: with_no_queries!( {
7775 let icx = ItemCtxt :: new( tcx, opaque_def_id) ;
7876 let mut bounds = icx. astconv( ) . compute_bounds( item_ty, ast_bounds, OnlySelfBounds ( false ) ) ;
7977 // Opaque types are implicitly sized unless a `?Sized` bound is found
8078 icx. astconv( ) . add_implicitly_sized( & mut bounds, item_ty, ast_bounds, None , span) ;
8179 debug!( ?bounds) ;
8280
83- tcx. arena. alloc_from_iter(
84- bounds. predicates( ) . map( |( clause, span) | ( clause. to_predicate( tcx) , span) ) ,
85- )
81+ tcx. arena. alloc_from_iter( bounds. clauses( ) )
8682 } )
8783}
8884
8985pub ( super ) fn explicit_item_bounds (
9086 tcx : TyCtxt < ' _ > ,
9187 def_id : LocalDefId ,
92- ) -> ty:: EarlyBinder < & ' _ [ ( ty:: Predicate < ' _ > , Span ) ] > {
88+ ) -> ty:: EarlyBinder < & ' _ [ ( ty:: Clause < ' _ > , Span ) ] > {
9389 match tcx. opt_rpitit_info ( def_id. to_def_id ( ) ) {
9490 // RPITIT's bounds are the same as opaque type bounds, but with
9591 // a projection self type.
@@ -141,11 +137,8 @@ pub(super) fn explicit_item_bounds(
141137pub ( super ) fn item_bounds (
142138 tcx : TyCtxt < ' _ > ,
143139 def_id : DefId ,
144- ) -> ty:: EarlyBinder < & ' _ ty:: List < ty:: Predicate < ' _ > > > {
140+ ) -> ty:: EarlyBinder < & ' _ ty:: List < ty:: Clause < ' _ > > > {
145141 tcx. explicit_item_bounds ( def_id) . map_bound ( |bounds| {
146- tcx. mk_predicates_from_iter ( util:: elaborate (
147- tcx,
148- bounds. iter ( ) . map ( |& ( bound, _span) | bound) ,
149- ) )
142+ tcx. mk_clauses_from_iter ( util:: elaborate ( tcx, bounds. iter ( ) . map ( |& ( bound, _span) | bound) ) )
150143 } )
151144}
0 commit comments