@@ -20,7 +20,7 @@ fn associated_type_bounds<'tcx>(
20
20
assoc_item_def_id : LocalDefId ,
21
21
ast_bounds : & ' tcx [ hir:: GenericBound < ' tcx > ] ,
22
22
span : Span ,
23
- ) -> & ' tcx [ ( ty:: Predicate < ' tcx > , Span ) ] {
23
+ ) -> & ' tcx [ ( ty:: Clause < ' tcx > , Span ) ] {
24
24
let item_ty = tcx. mk_projection (
25
25
assoc_item_def_id. to_def_id ( ) ,
26
26
InternalSubsts :: identity_for_item ( tcx, assoc_item_def_id) ,
@@ -34,8 +34,11 @@ fn associated_type_bounds<'tcx>(
34
34
let trait_def_id = tcx. local_parent ( assoc_item_def_id) ;
35
35
let trait_predicates = tcx. trait_explicit_predicates_and_bounds ( trait_def_id) ;
36
36
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 ( ) {
39
42
ty:: PredicateKind :: Clause ( ty:: ClauseKind :: Trait ( tr) ) => tr. self_ty ( ) == item_ty,
40
43
ty:: PredicateKind :: Clause ( ty:: ClauseKind :: Projection ( proj) ) => {
41
44
proj. projection_ty . self_ty ( ) == item_ty
@@ -44,15 +47,10 @@ fn associated_type_bounds<'tcx>(
44
47
outlives. 0 == item_ty
45
48
}
46
49
_ => false ,
47
- }
48
- } ) ;
50
+ } )
51
+ . map ( | ( pred , span ) | ( pred . as_clause ( ) . unwrap ( ) , span ) ) ;
49
52
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) ) ;
56
54
debug ! (
57
55
"associated_type_bounds({}) = {:?}" ,
58
56
tcx. def_path_str( assoc_item_def_id. to_def_id( ) ) ,
@@ -72,24 +70,22 @@ fn opaque_type_bounds<'tcx>(
72
70
ast_bounds : & ' tcx [ hir:: GenericBound < ' tcx > ] ,
73
71
item_ty : Ty < ' tcx > ,
74
72
span : Span ,
75
- ) -> & ' tcx [ ( ty:: Predicate < ' tcx > , Span ) ] {
73
+ ) -> & ' tcx [ ( ty:: Clause < ' tcx > , Span ) ] {
76
74
ty:: print:: with_no_queries!( {
77
75
let icx = ItemCtxt :: new( tcx, opaque_def_id) ;
78
76
let mut bounds = icx. astconv( ) . compute_bounds( item_ty, ast_bounds, OnlySelfBounds ( false ) ) ;
79
77
// Opaque types are implicitly sized unless a `?Sized` bound is found
80
78
icx. astconv( ) . add_implicitly_sized( & mut bounds, item_ty, ast_bounds, None , span) ;
81
79
debug!( ?bounds) ;
82
80
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( ) )
86
82
} )
87
83
}
88
84
89
85
pub ( super ) fn explicit_item_bounds (
90
86
tcx : TyCtxt < ' _ > ,
91
87
def_id : LocalDefId ,
92
- ) -> ty:: EarlyBinder < & ' _ [ ( ty:: Predicate < ' _ > , Span ) ] > {
88
+ ) -> ty:: EarlyBinder < & ' _ [ ( ty:: Clause < ' _ > , Span ) ] > {
93
89
match tcx. opt_rpitit_info ( def_id. to_def_id ( ) ) {
94
90
// RPITIT's bounds are the same as opaque type bounds, but with
95
91
// a projection self type.
@@ -141,11 +137,8 @@ pub(super) fn explicit_item_bounds(
141
137
pub ( super ) fn item_bounds (
142
138
tcx : TyCtxt < ' _ > ,
143
139
def_id : DefId ,
144
- ) -> ty:: EarlyBinder < & ' _ ty:: List < ty:: Predicate < ' _ > > > {
140
+ ) -> ty:: EarlyBinder < & ' _ ty:: List < ty:: Clause < ' _ > > > {
145
141
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) ) )
150
143
} )
151
144
}
0 commit comments