@@ -19,7 +19,7 @@ fn associated_type_bounds<'tcx>(
1919 assoc_item_def_id : LocalDefId ,
2020 ast_bounds : & ' tcx [ hir:: GenericBound < ' tcx > ] ,
2121 span : Span ,
22- ) -> & ' tcx [ ( ty:: Predicate < ' tcx > , Span ) ] {
22+ ) -> & ' tcx [ ( ty:: Clause < ' tcx > , Span ) ] {
2323 let item_ty = tcx. mk_projection (
2424 assoc_item_def_id. to_def_id ( ) ,
2525 InternalSubsts :: identity_for_item ( tcx, assoc_item_def_id) ,
@@ -33,8 +33,11 @@ fn associated_type_bounds<'tcx>(
3333 let trait_def_id = tcx. local_parent ( assoc_item_def_id) ;
3434 let trait_predicates = tcx. trait_explicit_predicates_and_bounds ( trait_def_id) ;
3535
36- let bounds_from_parent = trait_predicates. predicates . iter ( ) . copied ( ) . filter ( |( pred, _) | {
37- match pred. kind ( ) . skip_binder ( ) {
36+ let bounds_from_parent = trait_predicates
37+ . predicates
38+ . iter ( )
39+ . copied ( )
40+ . filter ( |( pred, _) | match pred. kind ( ) . skip_binder ( ) {
3841 ty:: PredicateKind :: Clause ( ty:: ClauseKind :: Trait ( tr) ) => tr. self_ty ( ) == item_ty,
3942 ty:: PredicateKind :: Clause ( ty:: ClauseKind :: Projection ( proj) ) => {
4043 proj. projection_ty . self_ty ( ) == item_ty
@@ -43,15 +46,10 @@ fn associated_type_bounds<'tcx>(
4346 outlives. 0 == item_ty
4447 }
4548 _ => false ,
46- }
47- } ) ;
49+ } )
50+ . map ( | ( pred , span ) | ( pred . expect_clause ( ) , span ) ) ;
4851
49- let all_bounds = tcx. arena . alloc_from_iter (
50- bounds
51- . clauses ( )
52- . map ( |( clause, span) | ( clause. as_predicate ( ) , span) )
53- . chain ( bounds_from_parent) ,
54- ) ;
52+ let all_bounds = tcx. arena . alloc_from_iter ( bounds. clauses ( ) . chain ( bounds_from_parent) ) ;
5553 debug ! (
5654 "associated_type_bounds({}) = {:?}" ,
5755 tcx. def_path_str( assoc_item_def_id. to_def_id( ) ) ,
@@ -71,23 +69,22 @@ fn opaque_type_bounds<'tcx>(
7169 ast_bounds : & ' tcx [ hir:: GenericBound < ' tcx > ] ,
7270 item_ty : Ty < ' tcx > ,
7371 span : Span ,
74- ) -> & ' tcx [ ( ty:: Predicate < ' tcx > , Span ) ] {
72+ ) -> & ' tcx [ ( ty:: Clause < ' tcx > , Span ) ] {
7573 ty:: print:: with_no_queries!( {
7674 let icx = ItemCtxt :: new( tcx, opaque_def_id) ;
7775 let mut bounds = icx. astconv( ) . compute_bounds( item_ty, ast_bounds, OnlySelfBounds ( false ) ) ;
7876 // Opaque types are implicitly sized unless a `?Sized` bound is found
7977 icx. astconv( ) . add_implicitly_sized( & mut bounds, item_ty, ast_bounds, None , span) ;
8078 debug!( ?bounds) ;
8179
82- tcx. arena
83- . alloc_from_iter( bounds. clauses( ) . map( |( clause, span) | ( clause. as_predicate( ) , span) ) )
80+ tcx. arena. alloc_from_iter( bounds. clauses( ) )
8481 } )
8582}
8683
8784pub ( super ) fn explicit_item_bounds (
8885 tcx : TyCtxt < ' _ > ,
8986 def_id : LocalDefId ,
90- ) -> ty:: EarlyBinder < & ' _ [ ( ty:: Predicate < ' _ > , Span ) ] > {
87+ ) -> ty:: EarlyBinder < & ' _ [ ( ty:: Clause < ' _ > , Span ) ] > {
9188 match tcx. opt_rpitit_info ( def_id. to_def_id ( ) ) {
9289 // RPITIT's bounds are the same as opaque type bounds, but with
9390 // a projection self type.
@@ -139,11 +136,8 @@ pub(super) fn explicit_item_bounds(
139136pub ( super ) fn item_bounds (
140137 tcx : TyCtxt < ' _ > ,
141138 def_id : DefId ,
142- ) -> ty:: EarlyBinder < & ' _ ty:: List < ty:: Predicate < ' _ > > > {
139+ ) -> ty:: EarlyBinder < & ' _ ty:: List < ty:: Clause < ' _ > > > {
143140 tcx. explicit_item_bounds ( def_id) . map_bound ( |bounds| {
144- tcx. mk_predicates_from_iter ( util:: elaborate (
145- tcx,
146- bounds. iter ( ) . map ( |& ( bound, _span) | bound) ,
147- ) )
141+ tcx. mk_clauses_from_iter ( util:: elaborate ( tcx, bounds. iter ( ) . map ( |& ( bound, _span) | bound) ) )
148142 } )
149143}
0 commit comments