about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorOliver Scherer <github35764891676564198441@oli-obk.de>2019-01-08 12:40:25 +0100
committerOliver Scherer <github35764891676564198441@oli-obk.de>2019-01-27 21:41:34 +0100
commit2a1748834e80b2461be4e18d420503d60e687312 (patch)
treeb6c43ba2d8b71ea5721939e9d54daa90df56d2e7 /src
parent1578955500ab438f80f27361b74a82364caa499f (diff)
downloadrust-2a1748834e80b2461be4e18d420503d60e687312.tar.gz
rust-2a1748834e80b2461be4e18d420503d60e687312.zip
Add some size assertions for const eval types
Diffstat (limited to 'src')
-rw-r--r--src/librustc/mir/interpret/pointer.rs2
-rw-r--r--src/librustc/mir/interpret/value.rs6
-rw-r--r--src/librustc/ty/sty.rs6
3 files changed, 14 insertions, 0 deletions
diff --git a/src/librustc/mir/interpret/pointer.rs b/src/librustc/mir/interpret/pointer.rs
index a046825f088..498c0b5b917 100644
--- a/src/librustc/mir/interpret/pointer.rs
+++ b/src/librustc/mir/interpret/pointer.rs
@@ -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)]
diff --git a/src/librustc/mir/interpret/value.rs b/src/librustc/mir/interpret/value.rs
index 76eb43e73d1..896e2ab960c 100644
--- a/src/librustc/mir/interpret/value.rs
+++ b/src/librustc/mir/interpret/value.rs
@@ -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 {
diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs
index b98369b62ea..a42b80e594c 100644
--- a/src/librustc/ty/sty.rs
+++ b/src/librustc/ty/sty.rs
@@ -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(