Rollup merge of #100003 - nnethercote:improve-size-assertions, r=lqd
Improve size assertions. - For any file with four or more size assertions, move them into a separate module (as is already done for `hir.rs`). - Add some more for AST nodes and THIR nodes. - Put the `hir.rs` ones in alphabetical order. r? `@lqd`
This commit is contained in:
@@ -37,9 +37,6 @@ pub enum Immediate<Prov: Provenance = AllocId> {
|
||||
Uninit,
|
||||
}
|
||||
|
||||
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
|
||||
rustc_data_structures::static_assert_size!(Immediate, 56);
|
||||
|
||||
impl<Prov: Provenance> From<ScalarMaybeUninit<Prov>> for Immediate<Prov> {
|
||||
#[inline(always)]
|
||||
fn from(val: ScalarMaybeUninit<Prov>) -> Self {
|
||||
@@ -117,9 +114,6 @@ pub struct ImmTy<'tcx, Prov: Provenance = AllocId> {
|
||||
pub layout: TyAndLayout<'tcx>,
|
||||
}
|
||||
|
||||
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
|
||||
rustc_data_structures::static_assert_size!(ImmTy<'_>, 72);
|
||||
|
||||
impl<Prov: Provenance> std::fmt::Display for ImmTy<'_, Prov> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
/// Helper function for printing a scalar to a FmtPrinter
|
||||
@@ -187,9 +181,6 @@ pub enum Operand<Prov: Provenance = AllocId> {
|
||||
Indirect(MemPlace<Prov>),
|
||||
}
|
||||
|
||||
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
|
||||
rustc_data_structures::static_assert_size!(Operand, 64);
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct OpTy<'tcx, Prov: Provenance = AllocId> {
|
||||
op: Operand<Prov>, // Keep this private; it helps enforce invariants.
|
||||
@@ -204,9 +195,6 @@ pub struct OpTy<'tcx, Prov: Provenance = AllocId> {
|
||||
pub align: Option<Align>,
|
||||
}
|
||||
|
||||
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
|
||||
rustc_data_structures::static_assert_size!(OpTy<'_>, 88);
|
||||
|
||||
impl<'tcx, Prov: Provenance> std::ops::Deref for OpTy<'tcx, Prov> {
|
||||
type Target = Operand<Prov>;
|
||||
#[inline(always)]
|
||||
@@ -830,3 +818,14 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
|
||||
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
|
||||
mod size_asserts {
|
||||
use super::*;
|
||||
// These are in alphabetical order, which is easy to maintain.
|
||||
rustc_data_structures::static_assert_size!(Immediate, 56);
|
||||
rustc_data_structures::static_assert_size!(ImmTy<'_>, 72);
|
||||
rustc_data_structures::static_assert_size!(Operand, 64);
|
||||
rustc_data_structures::static_assert_size!(OpTy<'_>, 88);
|
||||
}
|
||||
|
||||
@@ -25,9 +25,6 @@ pub enum MemPlaceMeta<Prov: Provenance = AllocId> {
|
||||
None,
|
||||
}
|
||||
|
||||
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
|
||||
rustc_data_structures::static_assert_size!(MemPlaceMeta, 24);
|
||||
|
||||
impl<Prov: Provenance> MemPlaceMeta<Prov> {
|
||||
pub fn unwrap_meta(self) -> Scalar<Prov> {
|
||||
match self {
|
||||
@@ -56,9 +53,6 @@ pub struct MemPlace<Prov: Provenance = AllocId> {
|
||||
pub meta: MemPlaceMeta<Prov>,
|
||||
}
|
||||
|
||||
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
|
||||
rustc_data_structures::static_assert_size!(MemPlace, 40);
|
||||
|
||||
/// A MemPlace with its layout. Constructing it is only possible in this module.
|
||||
#[derive(Copy, Clone, Hash, Eq, PartialEq, Debug)]
|
||||
pub struct MPlaceTy<'tcx, Prov: Provenance = AllocId> {
|
||||
@@ -71,9 +65,6 @@ pub struct MPlaceTy<'tcx, Prov: Provenance = AllocId> {
|
||||
pub align: Align,
|
||||
}
|
||||
|
||||
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
|
||||
rustc_data_structures::static_assert_size!(MPlaceTy<'_>, 64);
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum Place<Prov: Provenance = AllocId> {
|
||||
/// A place referring to a value allocated in the `Memory` system.
|
||||
@@ -84,9 +75,6 @@ pub enum Place<Prov: Provenance = AllocId> {
|
||||
Local { frame: usize, local: mir::Local },
|
||||
}
|
||||
|
||||
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
|
||||
rustc_data_structures::static_assert_size!(Place, 48);
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct PlaceTy<'tcx, Prov: Provenance = AllocId> {
|
||||
place: Place<Prov>, // Keep this private; it helps enforce invariants.
|
||||
@@ -98,9 +86,6 @@ pub struct PlaceTy<'tcx, Prov: Provenance = AllocId> {
|
||||
pub align: Align,
|
||||
}
|
||||
|
||||
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
|
||||
rustc_data_structures::static_assert_size!(PlaceTy<'_>, 72);
|
||||
|
||||
impl<'tcx, Prov: Provenance> std::ops::Deref for PlaceTy<'tcx, Prov> {
|
||||
type Target = Place<Prov>;
|
||||
#[inline(always)]
|
||||
@@ -901,3 +886,15 @@ where
|
||||
Ok(mplace)
|
||||
}
|
||||
}
|
||||
|
||||
// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
|
||||
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
|
||||
mod size_asserts {
|
||||
use super::*;
|
||||
// These are in alphabetical order, which is easy to maintain.
|
||||
rustc_data_structures::static_assert_size!(MemPlaceMeta, 24);
|
||||
rustc_data_structures::static_assert_size!(MemPlace, 40);
|
||||
rustc_data_structures::static_assert_size!(MPlaceTy<'_>, 64);
|
||||
rustc_data_structures::static_assert_size!(Place, 48);
|
||||
rustc_data_structures::static_assert_size!(PlaceTy<'_>, 72);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user