Skip to content

Commit d565d51

Browse files
committed
Put size assertions together.
As has already been done in various other places in the compiler.
1 parent 0ebd3ab commit d565d51

File tree

1 file changed

+11
-13
lines changed
  • compiler/rustc_middle/src/ty

1 file changed

+11
-13
lines changed

compiler/rustc_middle/src/ty/mod.rs

+11-13
Original file line numberDiff line numberDiff line change
@@ -463,15 +463,6 @@ pub(crate) struct TyS<'tcx> {
463463
outer_exclusive_binder: ty::DebruijnIndex,
464464
}
465465

466-
// `TyS` is used a lot. Make sure it doesn't unintentionally get bigger.
467-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
468-
static_assert_size!(TyS<'_>, 40);
469-
470-
// We are actually storing a stable hash cache next to the type, so let's
471-
// also check the full size
472-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
473-
static_assert_size!(WithStableHash<TyS<'_>>, 56);
474-
475466
/// Use this rather than `TyS`, whenever possible.
476467
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable)]
477468
#[rustc_diagnostic_item = "Ty"]
@@ -528,10 +519,6 @@ pub(crate) struct PredicateS<'tcx> {
528519
outer_exclusive_binder: ty::DebruijnIndex,
529520
}
530521

531-
// This type is used a lot. Make sure it doesn't unintentionally get bigger.
532-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
533-
static_assert_size!(PredicateS<'_>, 56);
534-
535522
/// Use this rather than `PredicateS`, whenever possible.
536523
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
537524
#[rustc_pass_by_value]
@@ -2534,3 +2521,14 @@ pub struct DestructuredConst<'tcx> {
25342521
pub variant: Option<VariantIdx>,
25352522
pub fields: &'tcx [ty::Const<'tcx>],
25362523
}
2524+
2525+
// Some types are used a lot. Make sure they don't unintentionally get bigger.
2526+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
2527+
mod size_asserts {
2528+
use super::*;
2529+
use rustc_data_structures::static_assert_size;
2530+
// These are in alphabetical order, which is easy to maintain.
2531+
static_assert_size!(PredicateS<'_>, 56);
2532+
static_assert_size!(TyS<'_>, 40);
2533+
static_assert_size!(WithStableHash<TyS<'_>>, 56);
2534+
}

0 commit comments

Comments
 (0)