@@ -261,9 +261,14 @@ impl<'tcx, O: Elaboratable<'tcx>> Elaborator<'tcx, O> {
261
261
fn elaborate ( & mut self , elaboratable : & O ) {
262
262
let tcx = self . visited . tcx ;
263
263
264
- let bound_predicate = elaboratable. predicate ( ) . kind ( ) ;
265
- match bound_predicate. skip_binder ( ) {
266
- ty:: PredicateKind :: Clause ( ty:: ClauseKind :: Trait ( data) ) => {
264
+ // We only elaborate clauses.
265
+ let Some ( clause) = elaboratable. predicate ( ) . as_clause ( ) else {
266
+ return ;
267
+ } ;
268
+
269
+ let bound_clause = clause. kind ( ) ;
270
+ match bound_clause. skip_binder ( ) {
271
+ ty:: ClauseKind :: Trait ( data) => {
267
272
// Negative trait bounds do not imply any supertrait bounds
268
273
if data. polarity == ty:: ImplPolarity :: Negative {
269
274
return ;
@@ -280,49 +285,16 @@ impl<'tcx, O: Elaboratable<'tcx>> Elaborator<'tcx, O> {
280
285
let obligations =
281
286
predicates. predicates . iter ( ) . enumerate ( ) . map ( |( index, & ( clause, span) ) | {
282
287
elaboratable. child_with_derived_cause (
283
- clause. subst_supertrait ( tcx, & bound_predicate . rebind ( data. trait_ref ) ) ,
288
+ clause. subst_supertrait ( tcx, & bound_clause . rebind ( data. trait_ref ) ) ,
284
289
span,
285
- bound_predicate . rebind ( data) ,
290
+ bound_clause . rebind ( data) ,
286
291
index,
287
292
)
288
293
} ) ;
289
294
debug ! ( ?data, ?obligations, "super_predicates" ) ;
290
295
self . extend_deduped ( obligations) ;
291
296
}
292
- ty:: PredicateKind :: Clause ( ty:: ClauseKind :: WellFormed ( ..) ) => {
293
- // Currently, we do not elaborate WF predicates,
294
- // although we easily could.
295
- }
296
- ty:: PredicateKind :: ObjectSafe ( ..) => {
297
- // Currently, we do not elaborate object-safe
298
- // predicates.
299
- }
300
- ty:: PredicateKind :: Subtype ( ..) => {
301
- // Currently, we do not "elaborate" predicates like `X <: Y`,
302
- // though conceivably we might.
303
- }
304
- ty:: PredicateKind :: Coerce ( ..) => {
305
- // Currently, we do not "elaborate" predicates like `X -> Y`,
306
- // though conceivably we might.
307
- }
308
- ty:: PredicateKind :: Clause ( ty:: ClauseKind :: Projection ( ..) ) => {
309
- // Nothing to elaborate in a projection predicate.
310
- }
311
- ty:: PredicateKind :: Clause ( ty:: ClauseKind :: ConstEvaluatable ( ..) ) => {
312
- // Currently, we do not elaborate const-evaluatable
313
- // predicates.
314
- }
315
- ty:: PredicateKind :: ConstEquate ( ..) => {
316
- // Currently, we do not elaborate const-equate
317
- // predicates.
318
- }
319
- ty:: PredicateKind :: Clause ( ty:: ClauseKind :: RegionOutlives ( ..) ) => {
320
- // Nothing to elaborate from `'a: 'b`.
321
- }
322
- ty:: PredicateKind :: Clause ( ty:: ClauseKind :: TypeOutlives ( ty:: OutlivesPredicate (
323
- ty_max,
324
- r_min,
325
- ) ) ) => {
297
+ ty:: ClauseKind :: TypeOutlives ( ty:: OutlivesPredicate ( ty_max, r_min) ) => {
326
298
// We know that `T: 'a` for some type `T`. We can
327
299
// often elaborate this. For example, if we know that
328
300
// `[U]: 'a`, that implies that `U: 'a`. Similarly, if
@@ -385,15 +357,25 @@ impl<'tcx, O: Elaboratable<'tcx>> Elaborator<'tcx, O> {
385
357
}
386
358
} )
387
359
. map ( |clause| {
388
- elaboratable. child ( bound_predicate . rebind ( clause) . to_predicate ( tcx) )
360
+ elaboratable. child ( bound_clause . rebind ( clause) . to_predicate ( tcx) )
389
361
} ) ,
390
362
) ;
391
363
}
392
- ty:: PredicateKind :: Ambiguous => { }
393
- ty:: PredicateKind :: AliasRelate ( ..) => {
394
- // No
364
+ ty:: ClauseKind :: RegionOutlives ( ..) => {
365
+ // Nothing to elaborate from `'a: 'b`.
366
+ }
367
+ ty:: ClauseKind :: WellFormed ( ..) => {
368
+ // Currently, we do not elaborate WF predicates,
369
+ // although we easily could.
370
+ }
371
+ ty:: ClauseKind :: Projection ( ..) => {
372
+ // Nothing to elaborate in a projection predicate.
373
+ }
374
+ ty:: ClauseKind :: ConstEvaluatable ( ..) => {
375
+ // Currently, we do not elaborate const-evaluatable
376
+ // predicates.
395
377
}
396
- ty:: PredicateKind :: Clause ( ty :: ClauseKind :: ConstArgHasType ( ..) ) => {
378
+ ty:: ClauseKind :: ConstArgHasType ( ..) => {
397
379
// Nothing to elaborate
398
380
}
399
381
}
0 commit comments