@@ -353,6 +353,9 @@ pub trait ConstantExt<'tcx>: Sized + std::fmt::Debug {
353
353
supposely_unreachable_fatal ! ( s, "TranslateUneval" ; { self , ucv} ) ;
354
354
} ) )
355
355
} else {
356
+ let param_env = s. param_env ( ) ;
357
+ let ty = s. base ( ) . tcx . type_of ( ucv. def ) ;
358
+ let ty = tcx. instantiate_and_normalize_erasing_regions ( ucv. args , param_env, ty) ;
356
359
let kind = if let Some ( assoc) = s. base ( ) . tcx . opt_associated_item ( ucv. def ) {
357
360
if assoc. trait_item_def_id . is_some ( ) {
358
361
// This must be a trait declaration constant
@@ -362,7 +365,6 @@ pub trait ConstantExt<'tcx>: Sized + std::fmt::Debug {
362
365
363
366
// Solve the trait obligations
364
367
let parent_def_id = tcx. parent ( ucv. def ) ;
365
- let param_env = s. param_env ( ) ;
366
368
let trait_refs = solve_item_traits ( s, param_env, parent_def_id, ucv. args , None ) ;
367
369
368
370
// Convert
@@ -384,7 +386,6 @@ pub trait ConstantExt<'tcx>: Sized + std::fmt::Debug {
384
386
trait_refs : vec ! [ ] ,
385
387
}
386
388
} ;
387
- let ty = s. base ( ) . tcx . type_of ( s. owner_id ( ) ) ;
388
389
let cv = kind. decorate ( ty. sinto ( s) , span. sinto ( s) ) ;
389
390
TranslateUnevalRes :: GlobalName ( cv)
390
391
}
@@ -414,10 +415,8 @@ impl<'tcx, S: UnderOwnerState<'tcx>> SInto<S, ConstantExpr> for ty::Const<'tcx>
414
415
let span = self . default_span ( s. base ( ) . tcx ) ;
415
416
match self . kind ( ) {
416
417
ty:: ConstKind :: Param ( p) => {
418
+ let ty = p. find_ty_from_env ( s. param_env ( ) ) ;
417
419
let kind = ConstantExprKind :: ConstRef { id : p. sinto ( s) } ;
418
- let tcx = s. base ( ) . tcx ;
419
- let param_env = tcx. param_env ( s. owner_id ( ) ) ;
420
- let ty = p. find_ty_from_env ( param_env) ;
421
420
kind. decorate ( ty. sinto ( s) , span. sinto ( s) )
422
421
}
423
422
ty:: ConstKind :: Infer ( ..) => fatal ! ( s[ span] , "ty::ConstKind::Infer node? {:#?}" , self ) ,
0 commit comments