@@ -124,26 +124,33 @@ pub(crate) fn codegen_constant<'tcx>(
124124) -> CValue < ' tcx > {
125125 let const_ = match fx. monomorphize ( constant. literal ) {
126126 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 } )
132128 if fx. tcx . is_static ( def. did ) =>
133129 {
134130 assert ! ( substs. is_empty( ) ) ;
135131 assert ! ( promoted. is_none( ) ) ;
136132
137133 return codegen_static_ref ( fx, def. did , fx. layout_of ( const_. ty ( ) ) ) . to_cvalue ( fx) ;
138134 }
139- ConstKind :: Unevaluated ( unevaluated) => {
135+ ConstantKind :: Unevaluated ( unevaluated) => {
140136 match fx. tcx . const_eval_resolve ( ParamEnv :: reveal_all ( ) , unevaluated, None ) {
141137 Ok ( const_val) => const_val,
142138 Err ( _) => {
143139 span_bug ! ( constant. span, "erroneous constant not captured by required_consts" ) ;
144140 }
145141 }
146142 }
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+ }
147154 ConstKind :: Param ( _)
148155 | ConstKind :: Infer ( _)
149156 | ConstKind :: Bound ( _, _)
0 commit comments