@@ -10,40 +10,49 @@ pub fn anonymize_predicate<'tcx>(
10
10
tcx : TyCtxt < ' tcx > ,
11
11
pred : & ty:: Predicate < ' tcx > ,
12
12
) -> ty:: Predicate < ' tcx > {
13
- match * pred {
14
- ty:: Predicate :: Trait ( ref data, constness) => {
15
- ty:: Predicate :: Trait ( tcx. anonymize_late_bound_regions ( data) , constness)
13
+ match pred. kind ( ) {
14
+ & ty:: PredicateKind :: Trait ( ref data, constness) => {
15
+ ty:: PredicateKind :: Trait ( tcx. anonymize_late_bound_regions ( data) , constness)
16
+ . to_predicate ( tcx)
16
17
}
17
18
18
- ty:: Predicate :: RegionOutlives ( ref data) => {
19
- ty:: Predicate :: RegionOutlives ( tcx. anonymize_late_bound_regions ( data) )
19
+ ty:: PredicateKind :: RegionOutlives ( data) => {
20
+ ty:: PredicateKind :: RegionOutlives ( tcx. anonymize_late_bound_regions ( data) )
21
+ . to_predicate ( tcx)
20
22
}
21
23
22
- ty:: Predicate :: TypeOutlives ( ref data) => {
23
- ty:: Predicate :: TypeOutlives ( tcx. anonymize_late_bound_regions ( data) )
24
+ ty:: PredicateKind :: TypeOutlives ( data) => {
25
+ ty:: PredicateKind :: TypeOutlives ( tcx. anonymize_late_bound_regions ( data) )
26
+ . to_predicate ( tcx)
24
27
}
25
28
26
- ty:: Predicate :: Projection ( ref data) => {
27
- ty:: Predicate :: Projection ( tcx. anonymize_late_bound_regions ( data) )
29
+ ty:: PredicateKind :: Projection ( data) => {
30
+ ty:: PredicateKind :: Projection ( tcx. anonymize_late_bound_regions ( data) ) . to_predicate ( tcx )
28
31
}
29
32
30
- ty:: Predicate :: WellFormed ( data) => ty:: Predicate :: WellFormed ( data) ,
33
+ & ty:: PredicateKind :: WellFormed ( data) => {
34
+ ty:: PredicateKind :: WellFormed ( data) . to_predicate ( tcx)
35
+ }
31
36
32
- ty:: Predicate :: ObjectSafe ( data) => ty:: Predicate :: ObjectSafe ( data) ,
37
+ & ty:: PredicateKind :: ObjectSafe ( data) => {
38
+ ty:: PredicateKind :: ObjectSafe ( data) . to_predicate ( tcx)
39
+ }
33
40
34
- ty:: Predicate :: ClosureKind ( closure_def_id, closure_substs, kind) => {
35
- ty:: Predicate :: ClosureKind ( closure_def_id, closure_substs, kind)
41
+ & ty:: PredicateKind :: ClosureKind ( closure_def_id, closure_substs, kind) => {
42
+ ty:: PredicateKind :: ClosureKind ( closure_def_id, closure_substs, kind) . to_predicate ( tcx )
36
43
}
37
44
38
- ty:: Predicate :: Subtype ( ref data) => {
39
- ty:: Predicate :: Subtype ( tcx. anonymize_late_bound_regions ( data) )
45
+ ty:: PredicateKind :: Subtype ( data) => {
46
+ ty:: PredicateKind :: Subtype ( tcx. anonymize_late_bound_regions ( data) ) . to_predicate ( tcx )
40
47
}
41
48
42
- ty:: Predicate :: ConstEvaluatable ( def_id, substs) => {
43
- ty:: Predicate :: ConstEvaluatable ( def_id, substs)
49
+ & ty:: PredicateKind :: ConstEvaluatable ( def_id, substs) => {
50
+ ty:: PredicateKind :: ConstEvaluatable ( def_id, substs) . to_predicate ( tcx )
44
51
}
45
52
46
- ty:: Predicate :: ConstEquate ( c1, c2) => ty:: Predicate :: ConstEquate ( c1, c2) ,
53
+ ty:: PredicateKind :: ConstEquate ( c1, c2) => {
54
+ ty:: PredicateKind :: ConstEquate ( c1, c2) . to_predicate ( tcx)
55
+ }
47
56
}
48
57
}
49
58
@@ -99,14 +108,14 @@ pub fn elaborate_trait_ref<'tcx>(
99
108
tcx : TyCtxt < ' tcx > ,
100
109
trait_ref : ty:: PolyTraitRef < ' tcx > ,
101
110
) -> Elaborator < ' tcx > {
102
- elaborate_predicates ( tcx, std:: iter:: once ( trait_ref. without_const ( ) . to_predicate ( ) ) )
111
+ elaborate_predicates ( tcx, std:: iter:: once ( trait_ref. without_const ( ) . to_predicate ( tcx ) ) )
103
112
}
104
113
105
114
pub fn elaborate_trait_refs < ' tcx > (
106
115
tcx : TyCtxt < ' tcx > ,
107
116
trait_refs : impl Iterator < Item = ty:: PolyTraitRef < ' tcx > > ,
108
117
) -> Elaborator < ' tcx > {
109
- let predicates = trait_refs. map ( |trait_ref| trait_ref. without_const ( ) . to_predicate ( ) ) ;
118
+ let predicates = trait_refs. map ( |trait_ref| trait_ref. without_const ( ) . to_predicate ( tcx ) ) ;
110
119
elaborate_predicates ( tcx, predicates)
111
120
}
112
121
@@ -145,8 +154,8 @@ impl Elaborator<'tcx> {
145
154
146
155
fn elaborate ( & mut self , obligation : & PredicateObligation < ' tcx > ) {
147
156
let tcx = self . visited . tcx ;
148
- match obligation. predicate {
149
- ty:: Predicate :: Trait ( ref data, _) => {
157
+ match obligation. predicate . kind ( ) {
158
+ ty:: PredicateKind :: Trait ( ref data, _) => {
150
159
// Get predicates declared on the trait.
151
160
let predicates = tcx. super_predicates_of ( data. def_id ( ) ) ;
152
161
@@ -167,36 +176,36 @@ impl Elaborator<'tcx> {
167
176
168
177
self . stack . extend ( obligations) ;
169
178
}
170
- ty:: Predicate :: WellFormed ( ..) => {
179
+ ty:: PredicateKind :: WellFormed ( ..) => {
171
180
// Currently, we do not elaborate WF predicates,
172
181
// although we easily could.
173
182
}
174
- ty:: Predicate :: ObjectSafe ( ..) => {
183
+ ty:: PredicateKind :: ObjectSafe ( ..) => {
175
184
// Currently, we do not elaborate object-safe
176
185
// predicates.
177
186
}
178
- ty:: Predicate :: Subtype ( ..) => {
187
+ ty:: PredicateKind :: Subtype ( ..) => {
179
188
// Currently, we do not "elaborate" predicates like `X <: Y`,
180
189
// though conceivably we might.
181
190
}
182
- ty:: Predicate :: Projection ( ..) => {
191
+ ty:: PredicateKind :: Projection ( ..) => {
183
192
// Nothing to elaborate in a projection predicate.
184
193
}
185
- ty:: Predicate :: ClosureKind ( ..) => {
194
+ ty:: PredicateKind :: ClosureKind ( ..) => {
186
195
// Nothing to elaborate when waiting for a closure's kind to be inferred.
187
196
}
188
- ty:: Predicate :: ConstEvaluatable ( ..) => {
197
+ ty:: PredicateKind :: ConstEvaluatable ( ..) => {
189
198
// Currently, we do not elaborate const-evaluatable
190
199
// predicates.
191
200
}
192
- ty:: Predicate :: ConstEquate ( ..) => {
201
+ ty:: PredicateKind :: ConstEquate ( ..) => {
193
202
// Currently, we do not elaborate const-equate
194
203
// predicates.
195
204
}
196
- ty:: Predicate :: RegionOutlives ( ..) => {
205
+ ty:: PredicateKind :: RegionOutlives ( ..) => {
197
206
// Nothing to elaborate from `'a: 'b`.
198
207
}
199
- ty:: Predicate :: TypeOutlives ( ref data) => {
208
+ ty:: PredicateKind :: TypeOutlives ( ref data) => {
200
209
// We know that `T: 'a` for some type `T`. We can
201
210
// often elaborate this. For example, if we know that
202
211
// `[U]: 'a`, that implies that `U: 'a`. Similarly, if
@@ -228,15 +237,15 @@ impl Elaborator<'tcx> {
228
237
if r. is_late_bound ( ) {
229
238
None
230
239
} else {
231
- Some ( ty:: Predicate :: RegionOutlives ( ty:: Binder :: dummy (
240
+ Some ( ty:: PredicateKind :: RegionOutlives ( ty:: Binder :: dummy (
232
241
ty:: OutlivesPredicate ( r, r_min) ,
233
242
) ) )
234
243
}
235
244
}
236
245
237
246
Component :: Param ( p) => {
238
247
let ty = tcx. mk_ty_param ( p. index , p. name ) ;
239
- Some ( ty:: Predicate :: TypeOutlives ( ty:: Binder :: dummy (
248
+ Some ( ty:: PredicateKind :: TypeOutlives ( ty:: Binder :: dummy (
240
249
ty:: OutlivesPredicate ( ty, r_min) ,
241
250
) ) )
242
251
}
@@ -250,8 +259,9 @@ impl Elaborator<'tcx> {
250
259
None
251
260
}
252
261
} )
253
- . filter ( |p| visited. insert ( p) )
254
- . map ( |p| predicate_obligation ( p, None ) ) ,
262
+ . map ( |predicate_kind| predicate_kind. to_predicate ( tcx) )
263
+ . filter ( |predicate| visited. insert ( predicate) )
264
+ . map ( |predicate| predicate_obligation ( predicate, None ) ) ,
255
265
) ;
256
266
}
257
267
}
@@ -317,7 +327,7 @@ impl<'tcx, I: Iterator<Item = PredicateObligation<'tcx>>> Iterator for FilterToT
317
327
318
328
fn next ( & mut self ) -> Option < ty:: PolyTraitRef < ' tcx > > {
319
329
while let Some ( obligation) = self . base_iterator . next ( ) {
320
- if let ty:: Predicate :: Trait ( data, _) = obligation. predicate {
330
+ if let ty:: PredicateKind :: Trait ( data, _) = obligation. predicate . kind ( ) {
321
331
return Some ( data. to_poly_trait_ref ( ) ) ;
322
332
}
323
333
}
0 commit comments