address review again

This commit is contained in:
b-naber 2022-09-14 15:35:24 +02:00
parent fa35afe8dc
commit a10dd1f340

View File

@ -121,25 +121,7 @@ pub(crate) fn codegen_constant<'tcx>(
ConstKind::Value(valtree) => { ConstKind::Value(valtree) => {
(fx.tcx.valtree_to_const_val((const_.ty(), valtree)), const_.ty()) (fx.tcx.valtree_to_const_val((const_.ty(), valtree)), const_.ty())
} }
ConstKind::Unevaluated(ty::Unevaluated { def, substs, promoted }) ConstKind::Unevaluated(_) => bug!("expected constant to be evaluated at this stage"),
if fx.tcx.is_static(def.did) =>
{
assert!(substs.is_empty());
assert_eq!(promoted, ());
return codegen_static_ref(fx, def.did, fx.layout_of(const_.ty())).to_cvalue(fx);
}
ConstKind::Unevaluated(unevaluated) => {
match fx.tcx.const_eval_resolve(ParamEnv::reveal_all(), unevaluated.expand(), None)
{
Ok(const_val) => (const_val, const_.ty()),
Err(_) => {
span_bug!(
constant.span,
"erroneous constant not captured by required_consts"
);
}
}
}
ConstKind::Param(_) ConstKind::Param(_)
| ConstKind::Infer(_) | ConstKind::Infer(_)
| ConstKind::Bound(_, _) | ConstKind::Bound(_, _)