@@ -10,34 +10,34 @@ pub fn anonymize_predicate<'tcx>(
10
10
tcx : TyCtxt < ' tcx > ,
11
11
pred : ty:: Predicate < ' tcx > ,
12
12
) -> ty:: Predicate < ' tcx > {
13
- let kind = pred. kint ( tcx ) ;
13
+ let kind = pred. kind ( ) ;
14
14
let new = match kind {
15
- ty:: PredicateKint :: ForAll ( binder) => {
16
- ty:: PredicateKint :: ForAll ( tcx. anonymize_late_bound_regions ( binder) )
15
+ ty:: PredicateKind :: ForAll ( binder) => {
16
+ ty:: PredicateKind :: ForAll ( tcx. anonymize_late_bound_regions ( binder) )
17
17
}
18
- & ty:: PredicateKint :: Trait ( data, constness) => ty:: PredicateKint :: Trait ( data, constness) ,
18
+ & ty:: PredicateKind :: Trait ( data, constness) => ty:: PredicateKind :: Trait ( data, constness) ,
19
19
20
- & ty:: PredicateKint :: RegionOutlives ( data) => ty:: PredicateKint :: RegionOutlives ( data) ,
20
+ & ty:: PredicateKind :: RegionOutlives ( data) => ty:: PredicateKind :: RegionOutlives ( data) ,
21
21
22
- & ty:: PredicateKint :: TypeOutlives ( data) => ty:: PredicateKint :: TypeOutlives ( data) ,
22
+ & ty:: PredicateKind :: TypeOutlives ( data) => ty:: PredicateKind :: TypeOutlives ( data) ,
23
23
24
- & ty:: PredicateKint :: Projection ( data) => ty:: PredicateKint :: Projection ( data) ,
24
+ & ty:: PredicateKind :: Projection ( data) => ty:: PredicateKind :: Projection ( data) ,
25
25
26
- & ty:: PredicateKint :: WellFormed ( data) => ty:: PredicateKint :: WellFormed ( data) ,
26
+ & ty:: PredicateKind :: WellFormed ( data) => ty:: PredicateKind :: WellFormed ( data) ,
27
27
28
- & ty:: PredicateKint :: ObjectSafe ( data) => ty:: PredicateKint :: ObjectSafe ( data) ,
28
+ & ty:: PredicateKind :: ObjectSafe ( data) => ty:: PredicateKind :: ObjectSafe ( data) ,
29
29
30
- & ty:: PredicateKint :: ClosureKind ( closure_def_id, closure_substs, kind) => {
31
- ty:: PredicateKint :: ClosureKind ( closure_def_id, closure_substs, kind)
30
+ & ty:: PredicateKind :: ClosureKind ( closure_def_id, closure_substs, kind) => {
31
+ ty:: PredicateKind :: ClosureKind ( closure_def_id, closure_substs, kind)
32
32
}
33
33
34
- & ty:: PredicateKint :: Subtype ( data) => ty:: PredicateKint :: Subtype ( data) ,
34
+ & ty:: PredicateKind :: Subtype ( data) => ty:: PredicateKind :: Subtype ( data) ,
35
35
36
- & ty:: PredicateKint :: ConstEvaluatable ( def_id, substs) => {
37
- ty:: PredicateKint :: ConstEvaluatable ( def_id, substs)
36
+ & ty:: PredicateKind :: ConstEvaluatable ( def_id, substs) => {
37
+ ty:: PredicateKind :: ConstEvaluatable ( def_id, substs)
38
38
}
39
39
40
- & ty:: PredicateKint :: ConstEquate ( c1, c2) => ty:: PredicateKint :: ConstEquate ( c1, c2) ,
40
+ & ty:: PredicateKind :: ConstEquate ( c1, c2) => ty:: PredicateKind :: ConstEquate ( c1, c2) ,
41
41
} ;
42
42
43
43
if new != * kind { new. to_predicate ( tcx) } else { pred }
@@ -145,22 +145,22 @@ fn predicate_obligation<'tcx>(
145
145
}
146
146
147
147
impl Elaborator < ' tcx > {
148
- pub fn filter_to_traits ( self ) -> FilterToTraits < Self > {
149
- FilterToTraits :: new ( self )
148
+ pub fn filter_to_traits ( self ) -> FilterToTraits < ' tcx , Self > {
149
+ FilterToTraits :: new ( self . visited . tcx , self )
150
150
}
151
151
152
152
fn elaborate ( & mut self , obligation : & PredicateObligation < ' tcx > ) {
153
153
let tcx = self . visited . tcx ;
154
- let pred = match obligation. predicate . kint ( tcx ) {
155
- // We have to be careful and rebind this whenever
154
+ let pred = match obligation. predicate . kind ( ) {
155
+ // We have to be careful and rebind this when
156
156
// dealing with a predicate further down.
157
- ty:: PredicateKint :: ForAll ( binder) => binder. skip_binder ( ) ,
157
+ ty:: PredicateKind :: ForAll ( binder) => binder. skip_binder ( ) . kind ( ) ,
158
158
pred => pred,
159
159
} ;
160
160
161
161
match pred {
162
- ty:: PredicateKint :: ForAll ( _) => bug ! ( "unexpected predicate: {:?}" , pred) ,
163
- ty:: PredicateKint :: Trait ( ref data, _) => {
162
+ ty:: PredicateKind :: ForAll ( _) => bug ! ( "unexpected predicate: {:?}" , pred) ,
163
+ ty:: PredicateKind :: Trait ( data, _) => {
164
164
// Get predicates declared on the trait.
165
165
let predicates = tcx. super_predicates_of ( data. def_id ( ) ) ;
166
166
@@ -181,36 +181,36 @@ impl Elaborator<'tcx> {
181
181
182
182
self . stack . extend ( obligations) ;
183
183
}
184
- ty:: PredicateKint :: WellFormed ( ..) => {
184
+ ty:: PredicateKind :: WellFormed ( ..) => {
185
185
// Currently, we do not elaborate WF predicates,
186
186
// although we easily could.
187
187
}
188
- ty:: PredicateKint :: ObjectSafe ( ..) => {
188
+ ty:: PredicateKind :: ObjectSafe ( ..) => {
189
189
// Currently, we do not elaborate object-safe
190
190
// predicates.
191
191
}
192
- ty:: PredicateKint :: Subtype ( ..) => {
192
+ ty:: PredicateKind :: Subtype ( ..) => {
193
193
// Currently, we do not "elaborate" predicates like `X <: Y`,
194
194
// though conceivably we might.
195
195
}
196
- ty:: PredicateKint :: Projection ( ..) => {
196
+ ty:: PredicateKind :: Projection ( ..) => {
197
197
// Nothing to elaborate in a projection predicate.
198
198
}
199
- ty:: PredicateKint :: ClosureKind ( ..) => {
199
+ ty:: PredicateKind :: ClosureKind ( ..) => {
200
200
// Nothing to elaborate when waiting for a closure's kind to be inferred.
201
201
}
202
- ty:: PredicateKint :: ConstEvaluatable ( ..) => {
202
+ ty:: PredicateKind :: ConstEvaluatable ( ..) => {
203
203
// Currently, we do not elaborate const-evaluatable
204
204
// predicates.
205
205
}
206
- ty:: PredicateKint :: ConstEquate ( ..) => {
206
+ ty:: PredicateKind :: ConstEquate ( ..) => {
207
207
// Currently, we do not elaborate const-equate
208
208
// predicates.
209
209
}
210
- ty:: PredicateKint :: RegionOutlives ( ..) => {
210
+ ty:: PredicateKind :: RegionOutlives ( ..) => {
211
211
// Nothing to elaborate from `'a: 'b`.
212
212
}
213
- ty:: PredicateKint :: TypeOutlives ( ty:: OutlivesPredicate ( ty_max, r_min) ) => {
213
+ ty:: PredicateKind :: TypeOutlives ( ty:: OutlivesPredicate ( ty_max, r_min) ) => {
214
214
// We know that `T: 'a` for some type `T`. We can
215
215
// often elaborate this. For example, if we know that
216
216
// `[U]: 'a`, that implies that `U: 'a`. Similarly, if
@@ -240,15 +240,15 @@ impl Elaborator<'tcx> {
240
240
if r. is_late_bound ( ) {
241
241
None
242
242
} else {
243
- Some ( ty:: PredicateKint :: RegionOutlives ( ty:: OutlivesPredicate (
243
+ Some ( ty:: PredicateKind :: RegionOutlives ( ty:: OutlivesPredicate (
244
244
r, r_min,
245
245
) ) )
246
246
}
247
247
}
248
248
249
249
Component :: Param ( p) => {
250
250
let ty = tcx. mk_ty_param ( p. index , p. name ) ;
251
- Some ( ty:: PredicateKint :: TypeOutlives ( ty:: OutlivesPredicate (
251
+ Some ( ty:: PredicateKind :: TypeOutlives ( ty:: OutlivesPredicate (
252
252
ty, r_min,
253
253
) ) )
254
254
}
@@ -293,7 +293,7 @@ impl Iterator for Elaborator<'tcx> {
293
293
// Supertrait iterator
294
294
///////////////////////////////////////////////////////////////////////////
295
295
296
- pub type Supertraits < ' tcx > = FilterToTraits < Elaborator < ' tcx > > ;
296
+ pub type Supertraits < ' tcx > = FilterToTraits < ' tcx , Elaborator < ' tcx > > ;
297
297
298
298
pub fn supertraits < ' tcx > (
299
299
tcx : TyCtxt < ' tcx > ,
@@ -315,22 +315,23 @@ pub fn transitive_bounds<'tcx>(
315
315
316
316
/// A filter around an iterator of predicates that makes it yield up
317
317
/// just trait references.
318
- pub struct FilterToTraits < I > {
318
+ pub struct FilterToTraits < ' tcx , I > {
319
+ tcx : TyCtxt < ' tcx > ,
319
320
base_iterator : I ,
320
321
}
321
322
322
- impl < I > FilterToTraits < I > {
323
- fn new ( base : I ) -> FilterToTraits < I > {
324
- FilterToTraits { base_iterator : base }
323
+ impl < ' tcx , I > FilterToTraits < ' tcx , I > {
324
+ fn new ( tcx : TyCtxt < ' tcx > , base : I ) -> FilterToTraits < ' tcx , I > {
325
+ FilterToTraits { tcx , base_iterator : base }
325
326
}
326
327
}
327
328
328
- impl < ' tcx , I : Iterator < Item = PredicateObligation < ' tcx > > > Iterator for FilterToTraits < I > {
329
+ impl < ' tcx , I : Iterator < Item = PredicateObligation < ' tcx > > > Iterator for FilterToTraits < ' tcx , I > {
329
330
type Item = ty:: PolyTraitRef < ' tcx > ;
330
331
331
332
fn next ( & mut self ) -> Option < ty:: PolyTraitRef < ' tcx > > {
332
333
while let Some ( obligation) = self . base_iterator . next ( ) {
333
- if let Some ( data) = obligation. predicate . to_opt_poly_trait_ref ( ) {
334
+ if let Some ( data) = obligation. predicate . to_opt_poly_trait_ref ( self . tcx ) {
334
335
return Some ( data) ;
335
336
}
336
337
}
0 commit comments