@@ -124,26 +124,33 @@ pub(crate) fn codegen_constant<'tcx>(
124
124
) -> CValue < ' tcx > {
125
125
let const_ = match fx. monomorphize ( constant. literal ) {
126
126
ConstantKind :: Ty ( ct) => ct,
127
- ConstantKind :: Val ( val, ty) => return codegen_const_value ( fx, val, ty) ,
128
- } ;
129
- let const_val = match const_. kind ( ) {
130
- ConstKind :: Value ( valtree) => fx. tcx . valtree_to_const_val ( ( const_. ty ( ) , valtree) ) ,
131
- ConstKind :: Unevaluated ( ty:: Unevaluated { def, substs, promoted } )
127
+ ConstantKind :: Unevaluated ( mir:: Unevaluated { def, substs, promoted } )
132
128
if fx. tcx . is_static ( def. did ) =>
133
129
{
134
130
assert ! ( substs. is_empty( ) ) ;
135
131
assert ! ( promoted. is_none( ) ) ;
136
132
137
133
return codegen_static_ref ( fx, def. did , fx. layout_of ( const_. ty ( ) ) ) . to_cvalue ( fx) ;
138
134
}
139
- ConstKind :: Unevaluated ( unevaluated) => {
135
+ ConstantKind :: Unevaluated ( unevaluated) => {
140
136
match fx. tcx . const_eval_resolve ( ParamEnv :: reveal_all ( ) , unevaluated, None ) {
141
137
Ok ( const_val) => const_val,
142
138
Err ( _) => {
143
139
span_bug ! ( constant. span, "erroneous constant not captured by required_consts" ) ;
144
140
}
145
141
}
146
142
}
143
+ ConstantKind :: Val ( val, ty) => return codegen_const_value ( fx, val, ty) ,
144
+ } ;
145
+ let const_val = match const_. kind ( ) {
146
+ ConstKind :: Value ( valtree) => fx. tcx . valtree_to_const_val ( ( const_. ty ( ) , valtree) ) ,
147
+ ConstKind :: Unevaluated ( ty:: Unevaluated { def, substs, promoted } )
148
+ if fx. tcx . is_static ( def. did ) =>
149
+ {
150
+ assert ! ( substs. is_empty( ) ) ;
151
+ assert ! ( promoted. is_none( ) ) ;
152
+ return codegen_static_ref ( fx, def. did , fx. layout_of ( const_. ty ( ) ) ) . to_cvalue ( fx) ;
153
+ }
147
154
ConstKind :: Param ( _)
148
155
| ConstKind :: Infer ( _)
149
156
| ConstKind :: Bound ( _, _)
0 commit comments