@@ -148,7 +148,7 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
148148 self . tcx . mk_param_from_def ( def)
149149 }
150150 }
151- GenericParamDefKind :: Const => unreachable ! ( ) ,
151+ GenericParamDefKind :: Const { .. } => unreachable ! ( ) ,
152152 } ) ;
153153
154154 if success. get ( ) {
@@ -214,7 +214,7 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
214214 p. map_bound ( |p| {
215215 match p {
216216 Trait ( existential_trait_ref) => {
217- let trait_ref = Binder :: bind ( existential_trait_ref)
217+ let trait_ref = Binder :: dummy ( existential_trait_ref)
218218 . with_self_ty ( self . tcx , dummy_self) ;
219219 let did = trait_ref. skip_binder ( ) . def_id ;
220220 let substs = trait_ref. skip_binder ( ) . substs ;
@@ -238,7 +238,7 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
238238 }
239239 Projection ( existential_projection) => {
240240 let projection_pred =
241- Binder :: bind ( existential_projection)
241+ Binder :: dummy ( existential_projection)
242242 . with_self_ty ( self . tcx , dummy_self) ;
243243 let item_def_id = projection_pred
244244 . skip_binder ( )
@@ -332,7 +332,7 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
332332
333333 /// Translate a region.
334334 fn translate_region ( & self , region : Region < ' tcx > ) -> Region < ' tcx > {
335- use rustc_middle:: ty:: BoundRegion :: BrNamed ;
335+ use rustc_middle:: ty:: BoundRegionKind :: * ;
336336 use rustc_middle:: ty:: RegionKind :: * ;
337337 use rustc_middle:: ty:: { EarlyBoundRegion , FreeRegion } ;
338338
@@ -376,102 +376,97 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
376376 predicate : Predicate < ' tcx > ,
377377 ) -> Option < Predicate < ' tcx > > {
378378 use rustc_middle:: ty:: {
379- Binder , OutlivesPredicate , PredicateAtom , PredicateKind , ProjectionPredicate ,
380- ProjectionTy , SubtypePredicate , ToPredicate , TraitPredicate , WithOptConstParam ,
379+ OutlivesPredicate , PredicateKind , ProjectionPredicate , ProjectionTy , SubtypePredicate ,
380+ ToPredicate , TraitPredicate , WithOptConstParam ,
381381 } ;
382382
383- Some ( match predicate. skip_binders ( ) {
384- PredicateAtom :: Trait ( pred, constness) => Binder :: bind ( PredicateAtom :: 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- } ,
383+ Some (
384+ match predicate. kind ( ) . skip_binder ( ) {
385+ PredicateKind :: Trait ( pred, constness) => PredicateKind :: Trait (
386+ if let Some ( ( target_def_id, target_substs) ) = self . translate_orig_substs (
387+ index_map,
388+ pred. trait_ref . def_id ,
389+ pred. trait_ref . substs ,
390+ ) {
391+ TraitPredicate {
392+ trait_ref : TraitRef {
393+ def_id : target_def_id,
394+ substs : target_substs,
395+ } ,
396+ }
397+ } else {
398+ return None ;
399+ } ,
400+ constness,
401+ ) ,
402+ PredicateKind :: RegionOutlives ( pred) => PredicateKind :: RegionOutlives ( {
403+ let l = self . translate_region ( pred. 0 ) ;
404+ let r = self . translate_region ( pred. 1 ) ;
405+ OutlivesPredicate ( l, r)
406+ } ) ,
407+ PredicateKind :: TypeOutlives ( pred) => PredicateKind :: TypeOutlives ( {
408+ let l = self . translate ( index_map, pred. 0 ) ;
409+ let r = self . translate_region ( pred. 1 ) ;
410+ OutlivesPredicate ( l, r)
411+ } ) ,
412+ PredicateKind :: Projection ( pred) => PredicateKind :: Projection (
413+ if let Some ( ( target_def_id, target_substs) ) = self . translate_orig_substs (
414+ index_map,
415+ pred. projection_ty . item_def_id ,
416+ pred. projection_ty . substs ,
417+ ) {
418+ ProjectionPredicate {
419+ projection_ty : ProjectionTy {
420+ substs : target_substs,
421+ item_def_id : target_def_id,
422+ } ,
423+ ty : self . translate ( index_map, & pred. ty ) ,
424+ }
425+ } else {
426+ return None ;
427+ } ,
428+ ) ,
429+ PredicateKind :: WellFormed ( ty) => {
430+ PredicateKind :: WellFormed ( self . translate ( index_map, ty) )
431+ }
432+ PredicateKind :: ObjectSafe ( did) => {
433+ PredicateKind :: ObjectSafe ( self . translate_orig ( did) )
434+ }
435+ PredicateKind :: ClosureKind ( did, substs, kind) => PredicateKind :: ClosureKind (
436+ self . translate_orig ( did) ,
437+ self . translate ( index_map, & substs) ,
438+ kind,
439+ ) ,
440+ PredicateKind :: Subtype ( pred) => PredicateKind :: Subtype ( {
441+ let l = self . translate ( index_map, pred. a ) ;
442+ let r = self . translate ( index_map, pred. b ) ;
443+ SubtypePredicate {
444+ a_is_expected : pred. a_is_expected ,
445+ a : l,
446+ b : r,
395447 }
396- } else {
397- return None ;
398- } ,
399- constness,
400- ) )
401- . potentially_quantified ( self . tcx , PredicateKind :: ForAll ) ,
402- PredicateAtom :: RegionOutlives ( pred) => Binder :: bind ( PredicateAtom :: RegionOutlives ( {
403- let l = self . translate_region ( pred. 0 ) ;
404- let r = self . translate_region ( pred. 1 ) ;
405- OutlivesPredicate ( l, r)
406- } ) )
407- . potentially_quantified ( self . tcx , PredicateKind :: ForAll ) ,
408- PredicateAtom :: TypeOutlives ( pred) => Binder :: bind ( PredicateAtom :: TypeOutlives ( {
409- let l = self . translate ( index_map, pred. 0 ) ;
410- let r = self . translate_region ( pred. 1 ) ;
411- OutlivesPredicate ( l, r)
412- } ) )
413- . potentially_quantified ( self . tcx , PredicateKind :: ForAll ) ,
414- PredicateAtom :: Projection ( pred) => Binder :: bind ( PredicateAtom :: Projection (
415- if let Some ( ( target_def_id, target_substs) ) = self . translate_orig_substs (
416- index_map,
417- pred. projection_ty . item_def_id ,
418- pred. projection_ty . substs ,
419- ) {
420- ProjectionPredicate {
421- projection_ty : ProjectionTy {
422- substs : target_substs,
423- item_def_id : target_def_id,
424- } ,
425- ty : self . translate ( index_map, & pred. ty ) ,
448+ } ) ,
449+ PredicateKind :: ConstEvaluatable ( param, orig_substs) => {
450+ if let Some ( ( target_def_id, target_substs) ) =
451+ self . translate_orig_substs ( index_map, param. did , orig_substs)
452+ {
453+ // TODO: We could probably use translated version for
454+ // `WithOptConstParam::const_param_did`
455+ let const_param = WithOptConstParam :: unknown ( target_def_id) ;
456+ PredicateKind :: ConstEvaluatable ( const_param, target_substs)
457+ } else {
458+ return None ;
426459 }
427- } else {
428- return None ;
429- } ,
430- ) )
431- . potentially_quantified ( self . tcx , PredicateKind :: ForAll ) ,
432- PredicateAtom :: WellFormed ( ty) => {
433- PredicateAtom :: WellFormed ( self . translate ( index_map, ty) ) . to_predicate ( self . tcx )
434- }
435- PredicateAtom :: ObjectSafe ( did) => {
436- PredicateAtom :: ObjectSafe ( self . translate_orig ( did) ) . to_predicate ( self . tcx )
437- }
438- PredicateAtom :: ClosureKind ( did, substs, kind) => PredicateAtom :: ClosureKind (
439- self . translate_orig ( did) ,
440- self . translate ( index_map, & substs) ,
441- kind,
442- )
443- . to_predicate ( self . tcx ) ,
444- PredicateAtom :: Subtype ( pred) => PredicateAtom :: Subtype ( {
445- let l = self . translate ( index_map, pred. a ) ;
446- let r = self . translate ( index_map, pred. b ) ;
447- SubtypePredicate {
448- a_is_expected : pred. a_is_expected ,
449- a : l,
450- b : r,
451- }
452- } )
453- . to_predicate ( self . tcx ) ,
454- PredicateAtom :: ConstEvaluatable ( param, orig_substs) => {
455- if let Some ( ( target_def_id, target_substs) ) =
456- self . translate_orig_substs ( index_map, param. did , orig_substs)
457- {
458- // TODO: We could probably use translated version for
459- // `WithOptConstParam::const_param_did`
460- let const_param = WithOptConstParam :: unknown ( target_def_id) ;
461- PredicateAtom :: ConstEvaluatable ( const_param, target_substs)
462- . to_predicate ( self . tcx )
463- } else {
464- return None ;
465460 }
461+ PredicateKind :: ConstEquate ( c1, c2) => PredicateKind :: ConstEquate (
462+ self . translate ( index_map, & c1) ,
463+ self . translate ( index_map, & c2) ,
464+ ) ,
465+ // NOTE: Only used for Chalk trait solver
466+ PredicateKind :: TypeWellFormedFromEnv ( _) => unimplemented ! ( ) ,
466467 }
467- PredicateAtom :: ConstEquate ( c1, c2) => PredicateAtom :: ConstEquate (
468- self . translate ( index_map, & c1) ,
469- self . translate ( index_map, & c2) ,
470- )
471468 . to_predicate ( self . tcx ) ,
472- // NOTE: Only used for Chalk trait solver
473- PredicateAtom :: TypeWellFormedFromEnv ( _) => unimplemented ! ( ) ,
474- } )
469+ )
475470 }
476471
477472 /// Translate a slice of predicates in the context of an item.
0 commit comments