pub enum Const<'tcx> {
Ty(Ty<'tcx>, Const<'tcx>),
Unevaluated(UnevaluatedConst<'tcx>, Ty<'tcx>),
Val(ConstValue<'tcx>, Ty<'tcx>),
}
Expand description
Constants
Variants§
Ty(Ty<'tcx>, Const<'tcx>)
This constant came from the type system.
Any way of turning ty::Const
into ConstValue
should go through valtree_to_const_val
;
this ensures that we consistently produce “clean” values without data in the padding or
anything like that.
FIXME(BoxyUwU): We should remove this Ty
and look up the type for params via ParamEnv
Unevaluated(UnevaluatedConst<'tcx>, Ty<'tcx>)
An unevaluated mir constant which is not part of the type system.
Note that Ty(ty::ConstKind::Unevaluated)
and this variant are not identical! Ty
will
always flow through a valtree, so all data not captured in the valtree is lost. This variant
directly uses the evaluated result of the given constant, including e.g. data stored in
padding.
Val(ConstValue<'tcx>, Ty<'tcx>)
This constant cannot go back into the type system, as it represents something the type system cannot handle (e.g. pointers).