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