@@ -376,102 +376,97 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
376376 predicate : Predicate < ' tcx > ,
377377 ) -> Option < Predicate < ' tcx > > {
378378 use rustc_middle:: ty:: {
379- CoercePredicate , OutlivesPredicate , PredicateKind , ProjectionPredicate , ProjectionTy ,
380- self , SubtypePredicate , ToPredicate , TraitPredicate , WithOptConstParam ,
379+ self , CoercePredicate , OutlivesPredicate , PredicateKind , ProjectionPredicate ,
380+ ProjectionTy , SubtypePredicate , ToPredicate , TraitPredicate , WithOptConstParam ,
381381 } ;
382382
383383 let pred = match predicate. kind ( ) . skip_binder ( ) {
384- PredicateKind :: Trait ( pred) => PredicateKind :: Trait (
385- if let Some ( ( target_def_id, target_substs) ) = self . translate_orig_substs (
386- index_map,
387- pred. trait_ref . def_id ,
388- pred. trait_ref . substs ,
389- ) {
390- TraitPredicate {
391- trait_ref : TraitRef {
392- def_id : target_def_id,
393- substs : target_substs,
394- } ,
395- constness : pred. constness ,
396- }
397- } else {
398- return None ;
399- } ,
400- ) ,
401- PredicateKind :: RegionOutlives ( pred) => PredicateKind :: RegionOutlives ( {
402- let l = self . translate_region ( pred. 0 ) ;
403- let r = self . translate_region ( pred. 1 ) ;
404- OutlivesPredicate ( l, r)
405- } ) ,
406- PredicateKind :: TypeOutlives ( pred) => PredicateKind :: TypeOutlives ( {
407- let l = self . translate ( index_map, pred. 0 ) ;
408- let r = self . translate_region ( pred. 1 ) ;
409- OutlivesPredicate ( l, r)
410- } ) ,
411- PredicateKind :: Projection ( pred) => PredicateKind :: Projection (
412- if let Some ( ( target_def_id, target_substs) ) = self . translate_orig_substs (
413- index_map,
414- pred. projection_ty . item_def_id ,
415- pred. projection_ty . substs ,
416- ) {
417- ProjectionPredicate {
418- projection_ty : ProjectionTy {
419- substs : target_substs,
420- item_def_id : target_def_id,
421- } ,
422- ty : self . translate ( index_map, pred. ty ) ,
423- }
424- } else {
425- return None ;
426- } ,
427- ) ,
428- PredicateKind :: WellFormed ( ty) => {
429- PredicateKind :: WellFormed ( self . translate ( index_map, ty) )
430- }
431- PredicateKind :: ObjectSafe ( did) => {
432- PredicateKind :: ObjectSafe ( self . translate_orig ( did) )
433- }
434- PredicateKind :: ClosureKind ( did, substs, kind) => PredicateKind :: ClosureKind (
435- self . translate_orig ( did) ,
436- self . translate ( index_map, substs) ,
437- kind,
438- ) ,
439- PredicateKind :: Subtype ( pred) => PredicateKind :: Subtype ( {
440- let l = self . translate ( index_map, pred. a ) ;
441- let r = self . translate ( index_map, pred. b ) ;
442- SubtypePredicate {
443- a_is_expected : pred. a_is_expected ,
444- a : l,
445- b : r,
384+ PredicateKind :: Trait ( pred) => PredicateKind :: Trait (
385+ if let Some ( ( target_def_id, target_substs) ) = self . translate_orig_substs (
386+ index_map,
387+ pred. trait_ref . def_id ,
388+ pred. trait_ref . substs ,
389+ ) {
390+ TraitPredicate {
391+ trait_ref : TraitRef {
392+ def_id : target_def_id,
393+ substs : target_substs,
394+ } ,
395+ constness : pred. constness ,
446396 }
447- } ) ,
448- PredicateKind :: Coerce ( pred) => PredicateKind :: Coerce ( {
449- let a = self . translate ( index_map, pred. a ) ;
450- let b = self . translate ( index_map, pred. b ) ;
451- CoercePredicate { a, b }
452- } ) ,
453- PredicateKind :: ConstEvaluatable ( uv) => {
454- if let Some ( ( target_def_id, target_substs) ) =
455- self . translate_orig_substs ( index_map, uv. def . did , uv. substs ( self . tcx ) )
456- {
457- // TODO: We could probably use translated version for
458- // `WithOptConstParam::const_param_did`
459- let const_param = WithOptConstParam :: unknown ( target_def_id) ;
460- PredicateKind :: ConstEvaluatable ( Unevaluated :: new (
461- const_param,
462- target_substs,
463- ) )
464- } else {
465- return None ;
397+ } else {
398+ return None ;
399+ } ,
400+ ) ,
401+ PredicateKind :: RegionOutlives ( pred) => PredicateKind :: RegionOutlives ( {
402+ let l = self . translate_region ( pred. 0 ) ;
403+ let r = self . translate_region ( pred. 1 ) ;
404+ OutlivesPredicate ( l, r)
405+ } ) ,
406+ PredicateKind :: TypeOutlives ( pred) => PredicateKind :: TypeOutlives ( {
407+ let l = self . translate ( index_map, pred. 0 ) ;
408+ let r = self . translate_region ( pred. 1 ) ;
409+ OutlivesPredicate ( l, r)
410+ } ) ,
411+ PredicateKind :: Projection ( pred) => PredicateKind :: Projection (
412+ if let Some ( ( target_def_id, target_substs) ) = self . translate_orig_substs (
413+ index_map,
414+ pred. projection_ty . item_def_id ,
415+ pred. projection_ty . substs ,
416+ ) {
417+ ProjectionPredicate {
418+ projection_ty : ProjectionTy {
419+ substs : target_substs,
420+ item_def_id : target_def_id,
421+ } ,
422+ ty : self . translate ( index_map, pred. ty ) ,
466423 }
424+ } else {
425+ return None ;
426+ } ,
427+ ) ,
428+ PredicateKind :: WellFormed ( ty) => {
429+ PredicateKind :: WellFormed ( self . translate ( index_map, ty) )
430+ }
431+ PredicateKind :: ObjectSafe ( did) => PredicateKind :: ObjectSafe ( self . translate_orig ( did) ) ,
432+ PredicateKind :: ClosureKind ( did, substs, kind) => PredicateKind :: ClosureKind (
433+ self . translate_orig ( did) ,
434+ self . translate ( index_map, substs) ,
435+ kind,
436+ ) ,
437+ PredicateKind :: Subtype ( pred) => PredicateKind :: Subtype ( {
438+ let l = self . translate ( index_map, pred. a ) ;
439+ let r = self . translate ( index_map, pred. b ) ;
440+ SubtypePredicate {
441+ a_is_expected : pred. a_is_expected ,
442+ a : l,
443+ b : r,
467444 }
468- PredicateKind :: ConstEquate ( c1, c2) => PredicateKind :: ConstEquate (
469- self . translate ( index_map, c1) ,
470- self . translate ( index_map, c2) ,
471- ) ,
472- // NOTE: Only used for Chalk trait solver
473- PredicateKind :: TypeWellFormedFromEnv ( _) => unimplemented ! ( ) ,
474- } ;
445+ } ) ,
446+ PredicateKind :: Coerce ( pred) => PredicateKind :: Coerce ( {
447+ let a = self . translate ( index_map, pred. a ) ;
448+ let b = self . translate ( index_map, pred. b ) ;
449+ CoercePredicate { a, b }
450+ } ) ,
451+ PredicateKind :: ConstEvaluatable ( uv) => {
452+ if let Some ( ( target_def_id, target_substs) ) =
453+ self . translate_orig_substs ( index_map, uv. def . did , uv. substs ( self . tcx ) )
454+ {
455+ // TODO: We could probably use translated version for
456+ // `WithOptConstParam::const_param_did`
457+ let const_param = WithOptConstParam :: unknown ( target_def_id) ;
458+ PredicateKind :: ConstEvaluatable ( Unevaluated :: new ( const_param, target_substs) )
459+ } else {
460+ return None ;
461+ }
462+ }
463+ PredicateKind :: ConstEquate ( c1, c2) => PredicateKind :: ConstEquate (
464+ self . translate ( index_map, c1) ,
465+ self . translate ( index_map, c2) ,
466+ ) ,
467+ // NOTE: Only used for Chalk trait solver
468+ PredicateKind :: TypeWellFormedFromEnv ( _) => unimplemented ! ( ) ,
469+ } ;
475470
476471 Some ( ty:: Binder :: dummy ( pred) . to_predicate ( self . tcx ) )
477472 }
0 commit comments