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