Skip to content

Commit 06bc64d

Browse files
committed
Overhaul Const.
Specifically, rename the `Const` struct as `ConstS` and re-introduce `Const` as this: ``` pub struct Const<'tcx>(&'tcx Interned<ConstS>); ``` This now matches `Ty` and `Predicate` more closely, including using pointer-based `eq` and `hash`. Notable changes: - `mk_const` now takes a `ConstS`. - `Const` was copy, despite being 48 bytes. Now `ConstS` is not, so need a we need separate arena for it, because we can't use the `Dropless` one any more. - Many `&'tcx Const<'tcx>`/`&Const<'tcx>` to `Const<'tcx>` changes - Many `ct.ty` to `ct.ty()` and `ct.val` to `ct.val()` changes. - Lots of tedious sigil fiddling.
1 parent 18e7b7e commit 06bc64d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ fn codegen_stmt<'tcx>(
668668
let times = fx
669669
.monomorphize(times)
670670
.eval(fx.tcx, ParamEnv::reveal_all())
671-
.val
671+
.val()
672672
.try_to_bits(fx.tcx.data_layout.pointer_size)
673673
.unwrap();
674674
if operand.layout().size.bytes() == 0 {

src/constant.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub(crate) fn check_constants(fx: &mut FunctionCx<'_, '_, '_>) -> bool {
4646
ConstantKind::Ty(ct) => ct,
4747
ConstantKind::Val(..) => continue,
4848
};
49-
match const_.val {
49+
match const_.val() {
5050
ConstKind::Value(_) => {}
5151
ConstKind::Unevaluated(unevaluated) => {
5252
if let Err(err) =
@@ -127,15 +127,15 @@ pub(crate) fn codegen_constant<'tcx>(
127127
ConstantKind::Ty(ct) => ct,
128128
ConstantKind::Val(val, ty) => return codegen_const_value(fx, val, ty),
129129
};
130-
let const_val = match const_.val {
130+
let const_val = match const_.val() {
131131
ConstKind::Value(const_val) => const_val,
132132
ConstKind::Unevaluated(ty::Unevaluated { def, substs, promoted })
133133
if fx.tcx.is_static(def.did) =>
134134
{
135135
assert!(substs.is_empty());
136136
assert!(promoted.is_none());
137137

138-
return codegen_static_ref(fx, def.did, fx.layout_of(const_.ty)).to_cvalue(fx);
138+
return codegen_static_ref(fx, def.did, fx.layout_of(const_.ty())).to_cvalue(fx);
139139
}
140140
ConstKind::Unevaluated(unevaluated) => {
141141
match fx.tcx.const_eval_resolve(ParamEnv::reveal_all(), unevaluated, None) {
@@ -152,7 +152,7 @@ pub(crate) fn codegen_constant<'tcx>(
152152
| ConstKind::Error(_) => unreachable!("{:?}", const_),
153153
};
154154

155-
codegen_const_value(fx, const_val, const_.ty)
155+
codegen_const_value(fx, const_val, const_.ty())
156156
}
157157

158158
pub(crate) fn codegen_const_value<'tcx>(
@@ -465,7 +465,7 @@ pub(crate) fn mir_operand_get_const_val<'tcx>(
465465
match operand {
466466
Operand::Constant(const_) => match const_.literal {
467467
ConstantKind::Ty(const_) => {
468-
fx.monomorphize(const_).eval(fx.tcx, ParamEnv::reveal_all()).val.try_to_value()
468+
fx.monomorphize(const_).eval(fx.tcx, ParamEnv::reveal_all()).val().try_to_value()
469469
}
470470
ConstantKind::Val(val, _) => Some(val),
471471
},

0 commit comments

Comments
 (0)