@@ -5,7 +5,6 @@ use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
5
5
use rustc_middle:: mir:: interpret:: {
6
6
read_target_uint, AllocId , ConstAllocation , ConstValue , ErrorHandled , GlobalAlloc , Scalar ,
7
7
} ;
8
- use rustc_middle:: ty:: ConstKind ;
9
8
use rustc_span:: DUMMY_SP ;
10
9
11
10
use cranelift_codegen:: ir:: GlobalValueData ;
@@ -42,15 +41,7 @@ pub(crate) fn check_constants(fx: &mut FunctionCx<'_, '_, '_>) -> bool {
42
41
let mut all_constants_ok = true ;
43
42
for constant in & fx. mir . required_consts {
44
43
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 ! ( ) ,
54
45
ConstantKind :: Unevaluated ( uv, _) => uv,
55
46
ConstantKind :: Val ( ..) => continue ,
56
47
} ;
@@ -118,7 +109,7 @@ pub(crate) fn codegen_constant<'tcx>(
118
109
) -> CValue < ' tcx > {
119
110
let ( const_val, ty) = match fx. monomorphize ( constant. literal ) {
120
111
ConstantKind :: Ty ( const_) => unreachable ! ( "{:?}" , const_) ,
121
- ConstantKind :: Unevaluated ( ty :: Unevaluated { def, substs, promoted } , ty)
112
+ ConstantKind :: Unevaluated ( mir :: UnevaluatedConst { def, substs, promoted } , ty)
122
113
if fx. tcx . is_static ( def. did ) =>
123
114
{
124
115
assert ! ( substs. is_empty( ) ) ;
@@ -499,7 +490,16 @@ pub(crate) fn mir_operand_get_const_val<'tcx>(
499
490
match & stmt. kind {
500
491
StatementKind :: Assign ( local_and_rvalue) if & local_and_rvalue. 0 == place => {
501
492
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
+ ) => {
503
503
if computed_const_val. is_some ( ) {
504
504
return None ; // local assigned twice
505
505
}
0 commit comments