mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 11:48:30 +00:00
implement valtrees as the type-system representation for constant values
This commit is contained in:
parent
ce2b3a9b4c
commit
9096b3e44f
@ -127,7 +127,7 @@ pub(crate) fn codegen_constant<'tcx>(
|
|||||||
ConstantKind::Val(val, ty) => return codegen_const_value(fx, val, ty),
|
ConstantKind::Val(val, ty) => return codegen_const_value(fx, val, ty),
|
||||||
};
|
};
|
||||||
let const_val = match const_.kind() {
|
let const_val = match const_.kind() {
|
||||||
ConstKind::Value(const_val) => const_val,
|
ConstKind::Value(valtree) => fx.tcx.valtree_to_const_val((const_.ty(), valtree)),
|
||||||
ConstKind::Unevaluated(ty::Unevaluated { def, substs, promoted })
|
ConstKind::Unevaluated(ty::Unevaluated { def, substs, promoted })
|
||||||
if fx.tcx.is_static(def.did) =>
|
if fx.tcx.is_static(def.did) =>
|
||||||
{
|
{
|
||||||
@ -468,9 +468,10 @@ pub(crate) fn mir_operand_get_const_val<'tcx>(
|
|||||||
) -> Option<ConstValue<'tcx>> {
|
) -> Option<ConstValue<'tcx>> {
|
||||||
match operand {
|
match operand {
|
||||||
Operand::Constant(const_) => match const_.literal {
|
Operand::Constant(const_) => match const_.literal {
|
||||||
ConstantKind::Ty(const_) => {
|
ConstantKind::Ty(const_) => fx
|
||||||
fx.monomorphize(const_).eval(fx.tcx, ParamEnv::reveal_all()).kind().try_to_value()
|
.monomorphize(const_)
|
||||||
}
|
.eval_for_mir(fx.tcx, ParamEnv::reveal_all())
|
||||||
|
.try_to_value(fx.tcx),
|
||||||
ConstantKind::Val(val, _) => Some(val),
|
ConstantKind::Val(val, _) => Some(val),
|
||||||
},
|
},
|
||||||
// FIXME(rust-lang/rust#85105): Casts like `IMM8 as u32` result in the const being stored
|
// FIXME(rust-lang/rust#85105): Casts like `IMM8 as u32` result in the const being stored
|
||||||
|
Loading…
Reference in New Issue
Block a user