@@ -151,14 +151,22 @@ impl Elaborator<'tcx> {
151
151
152
152
fn elaborate ( & mut self , obligation : & PredicateObligation < ' tcx > ) {
153
153
let tcx = self . visited . tcx ;
154
- match obligation. predicate . kind ( ) {
155
- ty:: PredicateKind :: Trait ( ref data, _) => {
154
+ let pred = match obligation. predicate . kint ( tcx) {
155
+ // We have to be careful and rebind this whenever
156
+ // dealing with a predicate further down.
157
+ ty:: PredicateKint :: ForAll ( binder) => binder. skip_binder ( ) ,
158
+ pred => pred,
159
+ } ;
160
+
161
+ match pred {
162
+ ty:: PredicateKint :: ForAll ( _) => bug ! ( "unexpected predicate: {:?}" , pred) ,
163
+ ty:: PredicateKint :: Trait ( ref data, _) => {
156
164
// Get predicates declared on the trait.
157
165
let predicates = tcx. super_predicates_of ( data. def_id ( ) ) ;
158
166
159
167
let obligations = predicates. predicates . iter ( ) . map ( |& ( pred, span) | {
160
168
predicate_obligation (
161
- pred. subst_supertrait ( tcx, & data. to_poly_trait_ref ( ) ) ,
169
+ pred. subst_supertrait ( tcx, & ty :: Binder :: bind ( data. trait_ref ) ) ,
162
170
Some ( span) ,
163
171
)
164
172
} ) ;
@@ -173,36 +181,36 @@ impl Elaborator<'tcx> {
173
181
174
182
self . stack . extend ( obligations) ;
175
183
}
176
- ty:: PredicateKind :: WellFormed ( ..) => {
184
+ ty:: PredicateKint :: WellFormed ( ..) => {
177
185
// Currently, we do not elaborate WF predicates,
178
186
// although we easily could.
179
187
}
180
- ty:: PredicateKind :: ObjectSafe ( ..) => {
188
+ ty:: PredicateKint :: ObjectSafe ( ..) => {
181
189
// Currently, we do not elaborate object-safe
182
190
// predicates.
183
191
}
184
- ty:: PredicateKind :: Subtype ( ..) => {
192
+ ty:: PredicateKint :: Subtype ( ..) => {
185
193
// Currently, we do not "elaborate" predicates like `X <: Y`,
186
194
// though conceivably we might.
187
195
}
188
- ty:: PredicateKind :: Projection ( ..) => {
196
+ ty:: PredicateKint :: Projection ( ..) => {
189
197
// Nothing to elaborate in a projection predicate.
190
198
}
191
- ty:: PredicateKind :: ClosureKind ( ..) => {
199
+ ty:: PredicateKint :: ClosureKind ( ..) => {
192
200
// Nothing to elaborate when waiting for a closure's kind to be inferred.
193
201
}
194
- ty:: PredicateKind :: ConstEvaluatable ( ..) => {
202
+ ty:: PredicateKint :: ConstEvaluatable ( ..) => {
195
203
// Currently, we do not elaborate const-evaluatable
196
204
// predicates.
197
205
}
198
- ty:: PredicateKind :: ConstEquate ( ..) => {
206
+ ty:: PredicateKint :: ConstEquate ( ..) => {
199
207
// Currently, we do not elaborate const-equate
200
208
// predicates.
201
209
}
202
- ty:: PredicateKind :: RegionOutlives ( ..) => {
210
+ ty:: PredicateKint :: RegionOutlives ( ..) => {
203
211
// Nothing to elaborate from `'a: 'b`.
204
212
}
205
- ty:: PredicateKind :: TypeOutlives ( ref data ) => {
213
+ ty:: PredicateKint :: TypeOutlives ( ty :: OutlivesPredicate ( ty_max , r_min ) ) => {
206
214
// We know that `T: 'a` for some type `T`. We can
207
215
// often elaborate this. For example, if we know that
208
216
// `[U]: 'a`, that implies that `U: 'a`. Similarly, if
@@ -217,8 +225,6 @@ impl Elaborator<'tcx> {
217
225
// consider this as evidence that `T: 'static`, but
218
226
// I'm a bit wary of such constructions and so for now
219
227
// I want to be conservative. --nmatsakis
220
- let ty_max = data. skip_binder ( ) . 0 ;
221
- let r_min = data. skip_binder ( ) . 1 ;
222
228
if r_min. is_late_bound ( ) {
223
229
return ;
224
230
}
0 commit comments