@@ -362,12 +362,12 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
362362 predicate : Predicate < ' tcx > ,
363363 ) -> Option < Predicate < ' tcx > > {
364364 use rustc_middle:: ty:: {
365- Binder , OutlivesPredicate , ProjectionPredicate , ProjectionTy , SubtypePredicate ,
366- TraitPredicate ,
365+ Binder , OutlivesPredicate , PredicateKind , ProjectionPredicate , ProjectionTy ,
366+ SubtypePredicate , ToPredicate , TraitPredicate ,
367367 } ;
368368
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 (
371371 Binder :: bind (
372372 if let Some ( ( target_def_id, target_substs) ) = self . translate_orig_substs (
373373 index_map,
@@ -384,48 +384,59 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
384384 return None ;
385385 } ,
386386 ) ,
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| {
391392 let l = self . translate_region ( r_pred. 0 ) ;
392393 let r = self . translate_region ( r_pred. 1 ) ;
393394 OutlivesPredicate ( l, r)
394395 } ) )
396+ . to_predicate ( self . tcx )
395397 }
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| {
398400 let l = self . translate ( index_map, & r_pred. 0 ) ;
399401 let r = self . translate_region ( r_pred. 1 ) ;
400402 OutlivesPredicate ( l, r)
401403 } ) )
404+ . to_predicate ( self . tcx )
402405 }
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) ,
424434 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| {
429440 let l = self . translate ( index_map, & s_pred. a ) ;
430441 let r = self . translate ( index_map, & s_pred. b ) ;
431442 SubtypePredicate {
@@ -434,20 +445,23 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
434445 b : r,
435446 }
436447 } ) )
448+ . to_predicate ( self . tcx )
437449 }
438- Predicate :: ConstEvaluatable ( orig_did, orig_substs) => {
450+ PredicateKind :: ConstEvaluatable ( orig_did, orig_substs) => {
439451 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)
441453 {
442- Predicate :: ConstEvaluatable ( target_def_id, target_substs)
454+ PredicateKind :: ConstEvaluatable ( target_def_id, target_substs)
455+ . to_predicate ( self . tcx )
443456 } else {
444457 return None ;
445458 }
446459 }
447- Predicate :: ConstEquate ( c1, c2) => Predicate :: ConstEquate (
460+ PredicateKind :: ConstEquate ( c1, c2) => PredicateKind :: ConstEquate (
448461 self . translate ( index_map, & c1) ,
449462 self . translate ( index_map, & c2) ,
450- ) ,
463+ )
464+ . to_predicate ( self . tcx ) ,
451465 } )
452466 }
453467
0 commit comments