@@ -23,7 +23,6 @@ use rustc_middle::ty::layout::{IntegerExt, TyAndLayout};
2323use rustc_middle:: ty:: {
2424 self , ExistentialProjection , GenericArgKind , GenericArgsRef , ParamEnv , Ty , TyCtxt ,
2525} ;
26- use rustc_span:: DUMMY_SP ;
2726use rustc_target:: abi:: Integer ;
2827use smallvec:: SmallVec ;
2928
@@ -685,21 +684,25 @@ fn push_const_param<'tcx>(tcx: TyCtxt<'tcx>, ct: ty::Const<'tcx>, output: &mut S
685684 ty:: ConstKind :: Param ( param) => {
686685 write ! ( output, "{}" , param. name)
687686 }
688- ty:: ConstKind :: Value ( ty, _ ) => {
687+ ty:: ConstKind :: Value ( ty, valtree ) => {
689688 match ty. kind ( ) {
690689 ty:: Int ( ity) => {
691690 // FIXME: directly extract the bits from a valtree instead of evaluating an
692691 // 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" ) ;
694695 let val = Integer :: from_int_ty ( & tcx, * ity) . size ( ) . sign_extend ( bits) as i128 ;
695696 write ! ( output, "{val}" )
696697 }
697698 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" ) ;
699702 write ! ( output, "{val}" )
700703 }
701704 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" ) ;
703706 write ! ( output, "{val}" )
704707 }
705708 _ => {
@@ -711,8 +714,9 @@ fn push_const_param<'tcx>(tcx: TyCtxt<'tcx>, ct: ty::Const<'tcx>, output: &mut S
711714 // avoiding collisions and will make the emitted type names shorter.
712715 let hash_short = tcx. with_stable_hashing_context ( |mut hcx| {
713716 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+ } ) ;
716720 hasher. finish :: < Hash64 > ( )
717721 } ) ;
718722
0 commit comments