Skip to content

Commit 6c9d7fb

Browse files
committed
Add size assertions for interpreter data structures
1 parent a143517 commit 6c9d7fb

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

compiler/rustc_mir/src/interpret/operand.rs

+9
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ pub enum Immediate<Tag = ()> {
3232
ScalarPair(ScalarMaybeUninit<Tag>, ScalarMaybeUninit<Tag>),
3333
}
3434

35+
#[cfg(target_arch = "x86_64")]
36+
rustc_data_structures::static_assert_size!(Immediate, 56);
37+
3538
impl<Tag> From<ScalarMaybeUninit<Tag>> for Immediate<Tag> {
3639
#[inline(always)]
3740
fn from(val: ScalarMaybeUninit<Tag>) -> Self {
@@ -92,6 +95,9 @@ pub struct ImmTy<'tcx, Tag = ()> {
9295
pub layout: TyAndLayout<'tcx>,
9396
}
9497

98+
#[cfg(target_arch = "x86_64")]
99+
rustc_data_structures::static_assert_size!(ImmTy<'_>, 72);
100+
95101
impl<Tag: Copy> std::fmt::Display for ImmTy<'tcx, Tag> {
96102
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
97103
/// Helper function for printing a scalar to a FmtPrinter
@@ -156,6 +162,9 @@ pub struct OpTy<'tcx, Tag = ()> {
156162
pub layout: TyAndLayout<'tcx>,
157163
}
158164

165+
#[cfg(target_arch = "x86_64")]
166+
rustc_data_structures::static_assert_size!(OpTy<'_, ()>, 80);
167+
159168
impl<'tcx, Tag> std::ops::Deref for OpTy<'tcx, Tag> {
160169
type Target = Operand<Tag>;
161170
#[inline(always)]

compiler/rustc_mir/src/interpret/place.rs

+15
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ pub enum MemPlaceMeta<Tag = ()> {
3333
Poison,
3434
}
3535

36+
#[cfg(target_arch = "x86_64")]
37+
rustc_data_structures::static_assert_size!(MemPlaceMeta, 24);
38+
3639
impl<Tag> MemPlaceMeta<Tag> {
3740
pub fn unwrap_meta(self) -> Scalar<Tag> {
3841
match self {
@@ -71,6 +74,9 @@ pub struct MemPlace<Tag = ()> {
7174
pub meta: MemPlaceMeta<Tag>,
7275
}
7376

77+
#[cfg(target_arch = "x86_64")]
78+
rustc_data_structures::static_assert_size!(MemPlace, 56);
79+
7480
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable)]
7581
pub enum Place<Tag = ()> {
7682
/// A place referring to a value allocated in the `Memory` system.
@@ -81,12 +87,18 @@ pub enum Place<Tag = ()> {
8187
Local { frame: usize, local: mir::Local },
8288
}
8389

90+
#[cfg(target_arch = "x86_64")]
91+
rustc_data_structures::static_assert_size!(Place, 64);
92+
8493
#[derive(Copy, Clone, Debug)]
8594
pub struct PlaceTy<'tcx, Tag = ()> {
8695
place: Place<Tag>, // Keep this private; it helps enforce invariants.
8796
pub layout: TyAndLayout<'tcx>,
8897
}
8998

99+
#[cfg(target_arch = "x86_64")]
100+
rustc_data_structures::static_assert_size!(PlaceTy<'_>, 80);
101+
90102
impl<'tcx, Tag> std::ops::Deref for PlaceTy<'tcx, Tag> {
91103
type Target = Place<Tag>;
92104
#[inline(always)]
@@ -102,6 +114,9 @@ pub struct MPlaceTy<'tcx, Tag = ()> {
102114
pub layout: TyAndLayout<'tcx>,
103115
}
104116

117+
#[cfg(target_arch = "x86_64")]
118+
rustc_data_structures::static_assert_size!(MPlaceTy<'_>, 72);
119+
105120
impl<'tcx, Tag> std::ops::Deref for MPlaceTy<'tcx, Tag> {
106121
type Target = MemPlace<Tag>;
107122
#[inline(always)]

0 commit comments

Comments
 (0)