@@ -362,12 +362,12 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
362
362
predicate : Predicate < ' tcx > ,
363
363
) -> Option < Predicate < ' tcx > > {
364
364
use rustc_middle:: ty:: {
365
- Binder , OutlivesPredicate , ProjectionPredicate , ProjectionTy , SubtypePredicate ,
366
- TraitPredicate ,
365
+ Binder , OutlivesPredicate , PredicateKind , ProjectionPredicate , ProjectionTy ,
366
+ SubtypePredicate , ToPredicate , TraitPredicate ,
367
367
} ;
368
368
369
- Some ( match predicate {
370
- Predicate :: Trait ( trait_predicate, constness) => Predicate :: Trait (
369
+ Some ( match predicate. kind ( ) {
370
+ PredicateKind :: Trait ( trait_predicate, constness) => PredicateKind :: Trait (
371
371
Binder :: bind (
372
372
if let Some ( ( target_def_id, target_substs) ) = self . translate_orig_substs (
373
373
index_map,
@@ -384,48 +384,59 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
384
384
return None ;
385
385
} ,
386
386
) ,
387
- constness,
388
- ) ,
389
- Predicate :: RegionOutlives ( region_outlives_predicate) => {
390
- Predicate :: RegionOutlives ( region_outlives_predicate. map_bound ( |r_pred| {
387
+ * constness,
388
+ )
389
+ . to_predicate ( self . tcx ) ,
390
+ PredicateKind :: RegionOutlives ( region_outlives_predicate) => {
391
+ PredicateKind :: RegionOutlives ( region_outlives_predicate. map_bound ( |r_pred| {
391
392
let l = self . translate_region ( r_pred. 0 ) ;
392
393
let r = self . translate_region ( r_pred. 1 ) ;
393
394
OutlivesPredicate ( l, r)
394
395
} ) )
396
+ . to_predicate ( self . tcx )
395
397
}
396
- Predicate :: TypeOutlives ( type_outlives_predicate) => {
397
- Predicate :: TypeOutlives ( type_outlives_predicate. map_bound ( |r_pred| {
398
+ PredicateKind :: TypeOutlives ( type_outlives_predicate) => {
399
+ PredicateKind :: TypeOutlives ( type_outlives_predicate. map_bound ( |r_pred| {
398
400
let l = self . translate ( index_map, & r_pred. 0 ) ;
399
401
let r = self . translate_region ( r_pred. 1 ) ;
400
402
OutlivesPredicate ( l, r)
401
403
} ) )
404
+ . to_predicate ( self . tcx )
402
405
}
403
- Predicate :: Projection ( projection_predicate) => Predicate :: Projection ( Binder :: bind (
404
- if let Some ( ( target_def_id, target_substs) ) = self . translate_orig_substs (
405
- index_map,
406
- projection_predicate. skip_binder ( ) . projection_ty . item_def_id ,
407
- projection_predicate. skip_binder ( ) . projection_ty . substs ,
408
- ) {
409
- ProjectionPredicate {
410
- projection_ty : ProjectionTy {
411
- substs : target_substs,
412
- item_def_id : target_def_id,
413
- } ,
414
- ty : self . translate ( index_map, & projection_predicate. skip_binder ( ) . ty ) ,
415
- }
416
- } else {
417
- return None ;
418
- } ,
419
- ) ) ,
420
- Predicate :: WellFormed ( ty) => Predicate :: WellFormed ( self . translate ( index_map, & ty) ) ,
421
- Predicate :: ObjectSafe ( did) => Predicate :: ObjectSafe ( self . translate_orig ( did) ) ,
422
- Predicate :: ClosureKind ( did, substs, kind) => Predicate :: ClosureKind (
423
- self . translate_orig ( did) ,
406
+ PredicateKind :: Projection ( projection_predicate) => {
407
+ PredicateKind :: Projection ( Binder :: bind (
408
+ if let Some ( ( target_def_id, target_substs) ) = self . translate_orig_substs (
409
+ index_map,
410
+ projection_predicate. skip_binder ( ) . projection_ty . item_def_id ,
411
+ projection_predicate. skip_binder ( ) . projection_ty . substs ,
412
+ ) {
413
+ ProjectionPredicate {
414
+ projection_ty : ProjectionTy {
415
+ substs : target_substs,
416
+ item_def_id : target_def_id,
417
+ } ,
418
+ ty : self . translate ( index_map, & projection_predicate. skip_binder ( ) . ty ) ,
419
+ }
420
+ } else {
421
+ return None ;
422
+ } ,
423
+ ) )
424
+ . to_predicate ( self . tcx )
425
+ }
426
+ PredicateKind :: WellFormed ( ty) => {
427
+ PredicateKind :: WellFormed ( self . translate ( index_map, & ty) ) . to_predicate ( self . tcx )
428
+ }
429
+ PredicateKind :: ObjectSafe ( did) => {
430
+ PredicateKind :: ObjectSafe ( self . translate_orig ( * did) ) . to_predicate ( self . tcx )
431
+ }
432
+ PredicateKind :: ClosureKind ( did, substs, kind) => PredicateKind :: ClosureKind (
433
+ self . translate_orig ( * did) ,
424
434
self . translate ( index_map, & substs) ,
425
- kind,
426
- ) ,
427
- Predicate :: Subtype ( subtype_predicate) => {
428
- Predicate :: Subtype ( subtype_predicate. map_bound ( |s_pred| {
435
+ * kind,
436
+ )
437
+ . to_predicate ( self . tcx ) ,
438
+ PredicateKind :: Subtype ( subtype_predicate) => {
439
+ PredicateKind :: Subtype ( subtype_predicate. map_bound ( |s_pred| {
429
440
let l = self . translate ( index_map, & s_pred. a ) ;
430
441
let r = self . translate ( index_map, & s_pred. b ) ;
431
442
SubtypePredicate {
@@ -434,20 +445,23 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
434
445
b : r,
435
446
}
436
447
} ) )
448
+ . to_predicate ( self . tcx )
437
449
}
438
- Predicate :: ConstEvaluatable ( orig_did, orig_substs) => {
450
+ PredicateKind :: ConstEvaluatable ( orig_did, orig_substs) => {
439
451
if let Some ( ( target_def_id, target_substs) ) =
440
- self . translate_orig_substs ( index_map, orig_did, orig_substs)
452
+ self . translate_orig_substs ( index_map, * orig_did, orig_substs)
441
453
{
442
- Predicate :: ConstEvaluatable ( target_def_id, target_substs)
454
+ PredicateKind :: ConstEvaluatable ( target_def_id, target_substs)
455
+ . to_predicate ( self . tcx )
443
456
} else {
444
457
return None ;
445
458
}
446
459
}
447
- Predicate :: ConstEquate ( c1, c2) => Predicate :: ConstEquate (
460
+ PredicateKind :: ConstEquate ( c1, c2) => PredicateKind :: ConstEquate (
448
461
self . translate ( index_map, & c1) ,
449
462
self . translate ( index_map, & c2) ,
450
- ) ,
463
+ )
464
+ . to_predicate ( self . tcx ) ,
451
465
} )
452
466
}
453
467
0 commit comments