@@ -8,7 +8,7 @@ use rustc_infer::infer::InferCtxt;
8
8
use rustc_middle:: ty:: {
9
9
fold:: { BottomUpFolder , TypeFoldable , TypeFolder } ,
10
10
subst:: { GenericArg , InternalSubsts , SubstsRef } ,
11
- GenericParamDefKind , ParamEnv , Predicate , Region , TraitRef , Ty , TyCtxt , Unevaluated ,
11
+ GenericParamDefKind , ParamEnv , Predicate , Region , Term , TraitRef , Ty , TyCtxt , Unevaluated ,
12
12
} ;
13
13
use std:: collections:: HashMap ;
14
14
@@ -164,18 +164,18 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
164
164
use rustc_middle:: ty:: ExistentialPredicate :: * ;
165
165
use rustc_middle:: ty:: TyKind ;
166
166
use rustc_middle:: ty:: TypeAndMut ;
167
- use rustc_middle:: ty:: { AdtDef , Binder , ExistentialProjection , ExistentialTraitRef } ;
167
+ use rustc_middle:: ty:: { Binder , ExistentialProjection , ExistentialTraitRef } ;
168
168
169
169
orig. fold_with ( & mut BottomUpFolder {
170
170
tcx : self . tcx ,
171
171
ty_op : |ty| {
172
172
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 ( ) ) => {
176
174
// we fold bottom-up, so the code above is invalid, as it assumes the
177
175
// 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
+ {
179
179
let target_adt = self . tcx . adt_def ( target_def_id) ;
180
180
self . tcx . mk_adt ( target_adt, substs)
181
181
} else {
@@ -261,7 +261,7 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
261
261
substs : self
262
262
. tcx
263
263
. intern_substs ( & target_substs[ 1 ..] ) ,
264
- ty ,
264
+ term : Term :: Ty ( ty ) ,
265
265
} )
266
266
} else {
267
267
success. set ( false ) ;
@@ -420,7 +420,10 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
420
420
substs : target_substs,
421
421
item_def_id : target_def_id,
422
422
} ,
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
+ } ,
424
427
}
425
428
} else {
426
429
return None ;
@@ -451,7 +454,7 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
451
454
} ) ,
452
455
PredicateKind :: ConstEvaluatable ( uv) => {
453
456
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 )
455
458
{
456
459
// TODO: We could probably use translated version for
457
460
// `WithOptConstParam::const_param_did`
0 commit comments