@@ -8,7 +8,7 @@ use rustc_infer::infer::InferCtxt;
88use rustc_middle:: ty:: {
99 fold:: { BottomUpFolder , TypeFoldable , TypeFolder } ,
1010 subst:: { GenericArg , InternalSubsts , SubstsRef } ,
11- GenericParamDefKind , ParamEnv , Predicate , Region , TraitRef , Ty , TyCtxt , Unevaluated ,
11+ GenericParamDefKind , ParamEnv , Predicate , Region , Term , TraitRef , Ty , TyCtxt , Unevaluated ,
1212} ;
1313use std:: collections:: HashMap ;
1414
@@ -164,18 +164,18 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
164164 use rustc_middle:: ty:: ExistentialPredicate :: * ;
165165 use rustc_middle:: ty:: TyKind ;
166166 use rustc_middle:: ty:: TypeAndMut ;
167- use rustc_middle:: ty:: { AdtDef , Binder , ExistentialProjection , ExistentialTraitRef } ;
167+ use rustc_middle:: ty:: { Binder , ExistentialProjection , ExistentialTraitRef } ;
168168
169169 orig. fold_with ( & mut BottomUpFolder {
170170 tcx : self . tcx ,
171171 ty_op : |ty| {
172172 match * ty. kind ( ) {
173- TyKind :: Adt ( & AdtDef { ref did, .. } , substs)
174- if self . needs_translation ( * did) =>
175- {
173+ TyKind :: Adt ( adt_def, substs) if self . needs_translation ( adt_def. did ( ) ) => {
176174 // we fold bottom-up, so the code above is invalid, as it assumes the
177175 // substs (that have been folded already) are yet untranslated
178- if let Some ( target_def_id) = ( self . translate_orig ) ( self . id_mapping , * did) {
176+ if let Some ( target_def_id) =
177+ ( self . translate_orig ) ( self . id_mapping , adt_def. did ( ) )
178+ {
179179 let target_adt = self . tcx . adt_def ( target_def_id) ;
180180 self . tcx . mk_adt ( target_adt, substs)
181181 } else {
@@ -261,7 +261,7 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
261261 substs : self
262262 . tcx
263263 . intern_substs ( & target_substs[ 1 ..] ) ,
264- ty ,
264+ term : Term :: Ty ( ty ) ,
265265 } )
266266 } else {
267267 success. set ( false ) ;
@@ -420,7 +420,10 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
420420 substs : target_substs,
421421 item_def_id : target_def_id,
422422 } ,
423- ty : self . translate ( index_map, pred. ty ) ,
423+ term : match pred. term {
424+ Term :: Ty ( ty) => Term :: Ty ( self . translate ( index_map, ty) ) ,
425+ Term :: Const ( _) => pred. term ,
426+ } ,
424427 }
425428 } else {
426429 return None ;
@@ -451,7 +454,7 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
451454 } ) ,
452455 PredicateKind :: ConstEvaluatable ( uv) => {
453456 if let Some ( ( target_def_id, target_substs) ) =
454- self . translate_orig_substs ( index_map, uv. def . did , uv. substs ( self . tcx ) )
457+ self . translate_orig_substs ( index_map, uv. def . did , uv. substs )
455458 {
456459 // TODO: We could probably use translated version for
457460 // `WithOptConstParam::const_param_did`
0 commit comments