diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-08-01 16:49:33 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-01 16:49:33 +0200 |
| commit | e6bb00fff51185f3d417b73bf32541b62e7c54db (patch) | |
| tree | 211b65ea10561ef4270d7bec40716803cd3c226c /compiler/rustc_const_eval/src | |
| parent | 1fa02dd3e958dad25d667fab2037d7a6d4ab3b37 (diff) | |
| parent | 9037ebba0c243e5415879a2ef20736b71a453fa6 (diff) | |
| download | rust-e6bb00fff51185f3d417b73bf32541b62e7c54db.tar.gz rust-e6bb00fff51185f3d417b73bf32541b62e7c54db.zip | |
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`
Diffstat (limited to 'compiler/rustc_const_eval/src')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/operand.rs | 23 | ||||
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/place.rs | 27 |
2 files changed, 23 insertions, 27 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/operand.rs b/compiler/rustc_const_eval/src/interpret/operand.rs index de284bd3bae..94ba62c160c 100644 --- a/compiler/rustc_const_eval/src/interpret/operand.rs +++ b/compiler/rustc_const_eval/src/interpret/operand.rs @@ -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); +} diff --git a/compiler/rustc_const_eval/src/interpret/place.rs b/compiler/rustc_const_eval/src/interpret/place.rs index 473da71a0ab..f4571a1ca3d 100644 --- a/compiler/rustc_const_eval/src/interpret/place.rs +++ b/compiler/rustc_const_eval/src/interpret/place.rs @@ -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); +} |
