mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Add some size assertions for const eval types
This commit is contained in:
parent
1578955500
commit
2a1748834e
@ -76,6 +76,8 @@ pub struct Pointer<Tag=(),Id=AllocId> {
|
||||
pub tag: Tag,
|
||||
}
|
||||
|
||||
static_assert!(POINTER_SIZE: ::std::mem::size_of::<Pointer>() == 16);
|
||||
|
||||
/// Produces a `Pointer` which points to the beginning of the Allocation
|
||||
impl From<AllocId> for Pointer {
|
||||
#[inline(always)]
|
||||
|
@ -32,6 +32,9 @@ pub enum ConstValue<'tcx> {
|
||||
ByRef(AllocId, &'tcx Allocation, Size),
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
static_assert!(CONST_SIZE: ::std::mem::size_of::<ConstValue<'static>>() == 56);
|
||||
|
||||
impl<'tcx> ConstValue<'tcx> {
|
||||
#[inline]
|
||||
pub fn try_to_scalar(&self) -> Option<Scalar> {
|
||||
@ -90,6 +93,9 @@ pub enum Scalar<Tag=(), Id=AllocId> {
|
||||
Ptr(Pointer<Tag, Id>),
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
static_assert!(SCALAR_SIZE: ::std::mem::size_of::<Scalar>() == 24);
|
||||
|
||||
impl<Tag> fmt::Display for Scalar<Tag> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
|
@ -2063,6 +2063,9 @@ pub enum LazyConst<'tcx> {
|
||||
Evaluated(Const<'tcx>),
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
static_assert!(LAZY_CONST_SIZE: ::std::mem::size_of::<LazyConst<'static>>() == 72);
|
||||
|
||||
impl<'tcx> LazyConst<'tcx> {
|
||||
pub fn map_evaluated<R>(self, f: impl FnOnce(Const<'tcx>) -> Option<R>) -> Option<R> {
|
||||
match self {
|
||||
@ -2089,6 +2092,9 @@ pub struct Const<'tcx> {
|
||||
pub val: ConstValue<'tcx>,
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
static_assert!(CONST_SIZE: ::std::mem::size_of::<Const<'static>>() == 64);
|
||||
|
||||
impl<'tcx> Const<'tcx> {
|
||||
#[inline]
|
||||
pub fn from_scalar(
|
||||
|
Loading…
Reference in New Issue
Block a user