@@ -5,7 +5,6 @@ use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
55use rustc_middle:: mir:: interpret:: {
66 read_target_uint, AllocId , ConstAllocation , ConstValue , ErrorHandled , GlobalAlloc , Scalar ,
77} ;
8- use rustc_middle:: ty:: ConstKind ;
98use rustc_span:: DUMMY_SP ;
109
1110use cranelift_codegen:: ir:: GlobalValueData ;
@@ -42,15 +41,7 @@ pub(crate) fn check_constants(fx: &mut FunctionCx<'_, '_, '_>) -> bool {
4241 let mut all_constants_ok = true ;
4342 for constant in & fx. mir . required_consts {
4443 let unevaluated = match fx. monomorphize ( constant. literal ) {
45- ConstantKind :: Ty ( ct) => match ct. kind ( ) {
46- ConstKind :: Unevaluated ( uv) => uv. expand ( ) ,
47- ConstKind :: Value ( _) => continue ,
48- ConstKind :: Param ( _)
49- | ConstKind :: Infer ( _)
50- | ConstKind :: Bound ( _, _)
51- | ConstKind :: Placeholder ( _)
52- | ConstKind :: Error ( _) => unreachable ! ( "{:?}" , ct) ,
53- } ,
44+ ConstantKind :: Ty ( _) => unreachable ! ( ) ,
5445 ConstantKind :: Unevaluated ( uv, _) => uv,
5546 ConstantKind :: Val ( ..) => continue ,
5647 } ;
@@ -118,7 +109,7 @@ pub(crate) fn codegen_constant<'tcx>(
118109) -> CValue < ' tcx > {
119110 let ( const_val, ty) = match fx. monomorphize ( constant. literal ) {
120111 ConstantKind :: Ty ( const_) => unreachable ! ( "{:?}" , const_) ,
121- ConstantKind :: Unevaluated ( ty :: Unevaluated { def, substs, promoted } , ty)
112+ ConstantKind :: Unevaluated ( mir :: UnevaluatedConst { def, substs, promoted } , ty)
122113 if fx. tcx . is_static ( def. did ) =>
123114 {
124115 assert ! ( substs. is_empty( ) ) ;
@@ -499,7 +490,16 @@ pub(crate) fn mir_operand_get_const_val<'tcx>(
499490 match & stmt. kind {
500491 StatementKind :: Assign ( local_and_rvalue) if & local_and_rvalue. 0 == place => {
501492 match & local_and_rvalue. 1 {
502- Rvalue :: Cast ( CastKind :: Misc , operand, ty) => {
493+ Rvalue :: Cast (
494+ CastKind :: IntToInt
495+ | CastKind :: FloatToFloat
496+ | CastKind :: FloatToInt
497+ | CastKind :: IntToFloat
498+ | CastKind :: FnPtrToPtr
499+ | CastKind :: PtrToPtr ,
500+ operand,
501+ ty,
502+ ) => {
503503 if computed_const_val. is_some ( ) {
504504 return None ; // local assigned twice
505505 }
0 commit comments