@@ -23,7 +23,6 @@ use rustc_middle::ty::layout::{IntegerExt, TyAndLayout};
23
23
use rustc_middle:: ty:: {
24
24
self , ExistentialProjection , GenericArgKind , GenericArgsRef , ParamEnv , Ty , TyCtxt ,
25
25
} ;
26
- use rustc_span:: DUMMY_SP ;
27
26
use rustc_target:: abi:: Integer ;
28
27
use smallvec:: SmallVec ;
29
28
@@ -685,21 +684,25 @@ fn push_const_param<'tcx>(tcx: TyCtxt<'tcx>, ct: ty::Const<'tcx>, output: &mut S
685
684
ty:: ConstKind :: Param ( param) => {
686
685
write ! ( output, "{}" , param. name)
687
686
}
688
- ty:: ConstKind :: Value ( ty, _ ) => {
687
+ ty:: ConstKind :: Value ( ty, valtree ) => {
689
688
match ty. kind ( ) {
690
689
ty:: Int ( ity) => {
691
690
// FIXME: directly extract the bits from a valtree instead of evaluating an
692
691
// already evaluated `Const` in order to get the bits.
693
- let bits = ct. eval_bits ( tcx, ty:: ParamEnv :: reveal_all ( ) ) ;
692
+ let bits = ct
693
+ . try_to_bits ( tcx, ty:: ParamEnv :: reveal_all ( ) )
694
+ . expect ( "expected monomorphic const in codegen" ) ;
694
695
let val = Integer :: from_int_ty ( & tcx, * ity) . size ( ) . sign_extend ( bits) as i128 ;
695
696
write ! ( output, "{val}" )
696
697
}
697
698
ty:: Uint ( _) => {
698
- let val = ct. eval_bits ( tcx, ty:: ParamEnv :: reveal_all ( ) ) ;
699
+ let val = ct
700
+ . try_to_bits ( tcx, ty:: ParamEnv :: reveal_all ( ) )
701
+ . expect ( "expected monomorphic const in codegen" ) ;
699
702
write ! ( output, "{val}" )
700
703
}
701
704
ty:: Bool => {
702
- let val = ct. try_eval_bool ( tcx , ty :: ParamEnv :: reveal_all ( ) ) . unwrap ( ) ;
705
+ let val = ct. try_to_bool ( ) . expect ( "expected monomorphic const in codegen" ) ;
703
706
write ! ( output, "{val}" )
704
707
}
705
708
_ => {
@@ -711,8 +714,9 @@ fn push_const_param<'tcx>(tcx: TyCtxt<'tcx>, ct: ty::Const<'tcx>, output: &mut S
711
714
// avoiding collisions and will make the emitted type names shorter.
712
715
let hash_short = tcx. with_stable_hashing_context ( |mut hcx| {
713
716
let mut hasher = StableHasher :: new ( ) ;
714
- let ct = ct. eval ( tcx, ty:: ParamEnv :: reveal_all ( ) , DUMMY_SP ) . unwrap ( ) ;
715
- hcx. while_hashing_spans ( false , |hcx| ct. hash_stable ( hcx, & mut hasher) ) ;
717
+ hcx. while_hashing_spans ( false , |hcx| {
718
+ ( ty, valtree) . hash_stable ( hcx, & mut hasher)
719
+ } ) ;
716
720
hasher. finish :: < Hash64 > ( )
717
721
} ) ;
718
722
0 commit comments