Fix up size asserts.

- Put them in the module that defines the type.
- Add some `WithCachedTypeInfo<T>` asserts for consistency.
This commit is contained in:
Nicholas Nethercote 2025-07-31 12:39:33 +10:00
parent cf95e45ec6
commit 7aec38b6d9
4 changed files with 26 additions and 14 deletions

View file

@ -2238,15 +2238,3 @@ pub struct DestructuredConst<'tcx> {
pub variant: Option<VariantIdx>,
pub fields: &'tcx [ty::Const<'tcx>],
}
// Some types are used a lot. Make sure they don't unintentionally get bigger.
#[cfg(target_pointer_width = "64")]
mod size_asserts {
use rustc_data_structures::static_assert_size;
use super::*;
// tidy-alphabetical-start
static_assert_size!(PredicateKind<'_>, 32);
static_assert_size!(WithCachedTypeInfo<TyKind<'_>>, 48);
// tidy-alphabetical-end
}

View file

@ -704,3 +704,15 @@ impl<'tcx> Predicate<'tcx> {
}
}
}
// Some types are used a lot. Make sure they don't unintentionally get bigger.
#[cfg(target_pointer_width = "64")]
mod size_asserts {
use rustc_data_structures::static_assert_size;
use super::*;
// tidy-alphabetical-start
static_assert_size!(PredicateKind<'_>, 32);
static_assert_size!(WithCachedTypeInfo<PredicateKind<'_>>, 56);
// tidy-alphabetical-end
}

View file

@ -495,3 +495,15 @@ impl BoundRegionKind {
}
}
}
// Some types are used a lot. Make sure they don't unintentionally get bigger.
#[cfg(target_pointer_width = "64")]
mod size_asserts {
use rustc_data_structures::static_assert_size;
use super::*;
// tidy-alphabetical-start
static_assert_size!(RegionKind<'_>, 20);
static_assert_size!(ty::WithCachedTypeInfo<RegionKind<'_>>, 48);
// tidy-alphabetical-end
}

View file

@ -2040,7 +2040,7 @@ mod size_asserts {
use super::*;
// tidy-alphabetical-start
static_assert_size!(ty::RegionKind<'_>, 20);
static_assert_size!(ty::TyKind<'_>, 24);
static_assert_size!(TyKind<'_>, 24);
static_assert_size!(ty::WithCachedTypeInfo<TyKind<'_>>, 48);
// tidy-alphabetical-end
}