@@ -80,14 +80,14 @@ pub struct Elaborator<'tcx, O> {
80
80
pub trait Elaboratable < ' tcx > {
81
81
fn predicate ( & self ) -> ty:: Predicate < ' tcx > ;
82
82
83
- // Makes a new `Self` but with a different predicate .
84
- fn child ( & self , predicate : ty:: Predicate < ' tcx > ) -> Self ;
83
+ // Makes a new `Self` but with a different clause that comes from elaboration .
84
+ fn child ( & self , clause : ty:: Clause < ' tcx > ) -> Self ;
85
85
86
- // Makes a new `Self` but with a different predicate and a different cause
87
- // code (if `Self` has one).
86
+ // Makes a new `Self` but with a different clause and a different cause
87
+ // code (if `Self` has one, such as [`PredicateObligation`] ).
88
88
fn child_with_derived_cause (
89
89
& self ,
90
- predicate : ty:: Predicate < ' tcx > ,
90
+ clause : ty:: Clause < ' tcx > ,
91
91
span : Span ,
92
92
parent_trait_pred : ty:: PolyTraitPredicate < ' tcx > ,
93
93
index : usize ,
@@ -99,18 +99,18 @@ impl<'tcx> Elaboratable<'tcx> for PredicateObligation<'tcx> {
99
99
self . predicate
100
100
}
101
101
102
- fn child ( & self , predicate : ty:: Predicate < ' tcx > ) -> Self {
102
+ fn child ( & self , clause : ty:: Clause < ' tcx > ) -> Self {
103
103
Obligation {
104
104
cause : self . cause . clone ( ) ,
105
105
param_env : self . param_env ,
106
106
recursion_depth : 0 ,
107
- predicate,
107
+ predicate : clause . as_predicate ( ) ,
108
108
}
109
109
}
110
110
111
111
fn child_with_derived_cause (
112
112
& self ,
113
- predicate : ty:: Predicate < ' tcx > ,
113
+ clause : ty:: Clause < ' tcx > ,
114
114
span : Span ,
115
115
parent_trait_pred : ty:: PolyTraitPredicate < ' tcx > ,
116
116
index : usize ,
@@ -123,7 +123,12 @@ impl<'tcx> Elaboratable<'tcx> for PredicateObligation<'tcx> {
123
123
span,
124
124
} ) )
125
125
} ) ;
126
- Obligation { cause, param_env : self . param_env , recursion_depth : 0 , predicate }
126
+ Obligation {
127
+ cause,
128
+ param_env : self . param_env ,
129
+ recursion_depth : 0 ,
130
+ predicate : clause. as_predicate ( ) ,
131
+ }
127
132
}
128
133
}
129
134
@@ -132,18 +137,18 @@ impl<'tcx> Elaboratable<'tcx> for ty::Predicate<'tcx> {
132
137
* self
133
138
}
134
139
135
- fn child ( & self , predicate : ty:: Predicate < ' tcx > ) -> Self {
136
- predicate
140
+ fn child ( & self , clause : ty:: Clause < ' tcx > ) -> Self {
141
+ clause . as_predicate ( )
137
142
}
138
143
139
144
fn child_with_derived_cause (
140
145
& self ,
141
- predicate : ty:: Predicate < ' tcx > ,
146
+ clause : ty:: Clause < ' tcx > ,
142
147
_span : Span ,
143
148
_parent_trait_pred : ty:: PolyTraitPredicate < ' tcx > ,
144
149
_index : usize ,
145
150
) -> Self {
146
- predicate
151
+ clause . as_predicate ( )
147
152
}
148
153
}
149
154
@@ -152,18 +157,18 @@ impl<'tcx> Elaboratable<'tcx> for (ty::Predicate<'tcx>, Span) {
152
157
self . 0
153
158
}
154
159
155
- fn child ( & self , predicate : ty:: Predicate < ' tcx > ) -> Self {
156
- ( predicate , self . 1 )
160
+ fn child ( & self , clause : ty:: Clause < ' tcx > ) -> Self {
161
+ ( clause . as_predicate ( ) , self . 1 )
157
162
}
158
163
159
164
fn child_with_derived_cause (
160
165
& self ,
161
- predicate : ty:: Predicate < ' tcx > ,
166
+ clause : ty:: Clause < ' tcx > ,
162
167
_span : Span ,
163
168
_parent_trait_pred : ty:: PolyTraitPredicate < ' tcx > ,
164
169
_index : usize ,
165
170
) -> Self {
166
- ( predicate , self . 1 )
171
+ ( clause . as_predicate ( ) , self . 1 )
167
172
}
168
173
}
169
174
@@ -172,18 +177,18 @@ impl<'tcx> Elaboratable<'tcx> for (ty::Clause<'tcx>, Span) {
172
177
self . 0 . as_predicate ( )
173
178
}
174
179
175
- fn child ( & self , predicate : ty:: Predicate < ' tcx > ) -> Self {
176
- ( predicate . expect_clause ( ) , self . 1 )
180
+ fn child ( & self , clause : ty:: Clause < ' tcx > ) -> Self {
181
+ ( clause , self . 1 )
177
182
}
178
183
179
184
fn child_with_derived_cause (
180
185
& self ,
181
- predicate : ty:: Predicate < ' tcx > ,
186
+ clause : ty:: Clause < ' tcx > ,
182
187
_span : Span ,
183
188
_parent_trait_pred : ty:: PolyTraitPredicate < ' tcx > ,
184
189
_index : usize ,
185
190
) -> Self {
186
- ( predicate . expect_clause ( ) , self . 1 )
191
+ ( clause , self . 1 )
187
192
}
188
193
}
189
194
@@ -192,18 +197,18 @@ impl<'tcx> Elaboratable<'tcx> for ty::Clause<'tcx> {
192
197
self . as_predicate ( )
193
198
}
194
199
195
- fn child ( & self , predicate : ty:: Predicate < ' tcx > ) -> Self {
196
- predicate . expect_clause ( )
200
+ fn child ( & self , clause : ty:: Clause < ' tcx > ) -> Self {
201
+ clause
197
202
}
198
203
199
204
fn child_with_derived_cause (
200
205
& self ,
201
- predicate : ty:: Predicate < ' tcx > ,
206
+ clause : ty:: Clause < ' tcx > ,
202
207
_span : Span ,
203
208
_parent_trait_pred : ty:: PolyTraitPredicate < ' tcx > ,
204
209
_index : usize ,
205
210
) -> Self {
206
- predicate . expect_clause ( )
211
+ clause
207
212
}
208
213
}
209
214
@@ -252,14 +257,13 @@ impl<'tcx, O: Elaboratable<'tcx>> Elaborator<'tcx, O> {
252
257
} ;
253
258
254
259
let obligations =
255
- predicates. predicates . iter ( ) . enumerate ( ) . map ( |( index, & ( mut pred , span) ) | {
260
+ predicates. predicates . iter ( ) . enumerate ( ) . map ( |( index, & ( mut clause , span) ) | {
256
261
// when parent predicate is non-const, elaborate it to non-const predicates.
257
262
if data. constness == ty:: BoundConstness :: NotConst {
258
- pred = pred . without_const ( tcx) ;
263
+ clause = clause . without_const ( tcx) ;
259
264
}
260
265
elaboratable. child_with_derived_cause (
261
- pred. subst_supertrait ( tcx, & bound_predicate. rebind ( data. trait_ref ) )
262
- . as_predicate ( ) ,
266
+ clause. subst_supertrait ( tcx, & bound_predicate. rebind ( data. trait_ref ) ) ,
263
267
span,
264
268
bound_predicate. rebind ( data) ,
265
269
index,
@@ -333,26 +337,25 @@ impl<'tcx, O: Elaboratable<'tcx>> Elaborator<'tcx, O> {
333
337
if r. is_late_bound ( ) {
334
338
None
335
339
} else {
336
- Some ( ty:: PredicateKind :: Clause ( ty:: ClauseKind :: RegionOutlives (
337
- ty :: OutlivesPredicate ( r, r_min) ,
340
+ Some ( ty:: ClauseKind :: RegionOutlives ( ty:: OutlivesPredicate (
341
+ r, r_min,
338
342
) ) )
339
343
}
340
344
}
341
345
342
346
Component :: Param ( p) => {
343
347
let ty = tcx. mk_ty_param ( p. index , p. name ) ;
344
- Some ( ty:: PredicateKind :: Clause ( ty:: ClauseKind :: TypeOutlives (
345
- ty:: OutlivesPredicate ( ty, r_min) ,
346
- ) ) )
348
+ Some ( ty:: ClauseKind :: TypeOutlives ( ty:: OutlivesPredicate ( ty, r_min) ) )
347
349
}
348
350
349
351
Component :: UnresolvedInferenceVariable ( _) => None ,
350
352
351
353
Component :: Alias ( alias_ty) => {
352
354
// We might end up here if we have `Foo<<Bar as Baz>::Assoc>: 'a`.
353
355
// With this, we can deduce that `<Bar as Baz>::Assoc: 'a`.
354
- Some ( ty:: PredicateKind :: Clause ( ty:: ClauseKind :: TypeOutlives (
355
- ty:: OutlivesPredicate ( alias_ty. to_ty ( tcx) , r_min) ,
356
+ Some ( ty:: ClauseKind :: TypeOutlives ( ty:: OutlivesPredicate (
357
+ alias_ty. to_ty ( tcx) ,
358
+ r_min,
356
359
) ) )
357
360
}
358
361
@@ -362,10 +365,9 @@ impl<'tcx, O: Elaboratable<'tcx>> Elaborator<'tcx, O> {
362
365
None
363
366
}
364
367
} )
365
- . map ( |predicate_kind| {
366
- bound_predicate. rebind ( predicate_kind) . to_predicate ( tcx)
367
- } )
368
- . map ( |predicate| elaboratable. child ( predicate) ) ,
368
+ . map ( |clause| {
369
+ elaboratable. child ( bound_predicate. rebind ( clause) . to_predicate ( tcx) )
370
+ } ) ,
369
371
) ;
370
372
}
371
373
ty:: PredicateKind :: Clause ( ty:: ClauseKind :: TypeWellFormedFromEnv ( ..) ) => {
0 commit comments