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