Simplify static_assert_sizes.

We want to run them on all 64-bit platforms.
This commit is contained in:
Nicholas Nethercote
2024-04-16 17:02:20 +10:00
parent 1cec373f65
commit 0d97669a17
36 changed files with 45 additions and 43 deletions
+1 -1
View File
@@ -3363,7 +3363,7 @@ fn try_from(item_kind: ItemKind) -> Result<ForeignItemKind, ItemKind> {
pub type ForeignItem = Item<ForeignItemKind>;
// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
mod size_asserts {
use super::*;
use rustc_data_structures::static_assert_size;
+1 -1
View File
@@ -1023,7 +1023,7 @@ fn hash_stable(&self, _hcx: &mut CTX, _hasher: &mut StableHasher) {
}
// Some types are used a lot. Make sure they don't unintentionally get bigger.
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
mod size_asserts {
use super::*;
use rustc_data_structures::static_assert_size;
+1 -1
View File
@@ -768,7 +768,7 @@ pub fn new(open: Spacing, close: Spacing) -> DelimSpacing {
}
// Some types are used a lot. Make sure they don't unintentionally get bigger.
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
mod size_asserts {
use super::*;
use rustc_data_structures::static_assert_size;
@@ -792,7 +792,7 @@ pub(crate) fn const_val_to_op(
}
// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
mod size_asserts {
use super::*;
use rustc_data_structures::static_assert_size;
@@ -1058,7 +1058,7 @@ pub(super) fn unpack_dyn_star<P: Projectable<'tcx, M::Provenance>>(
}
// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
mod size_asserts {
use super::*;
use rustc_data_structures::static_assert_size;
+2 -2
View File
@@ -102,9 +102,9 @@
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
// `PResult` is used a lot. Make sure it doesn't unintentionally get bigger.
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
rustc_data_structures::static_assert_size!(PResult<'_, ()>, 16);
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
rustc_data_structures::static_assert_size!(PResult<'_, bool>, 16);
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, Encodable, Decodable)]
@@ -266,7 +266,7 @@ struct MatcherPos {
}
// This type is used a lot. Make sure it doesn't unintentionally get bigger.
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
rustc_data_structures::static_assert_size!(MatcherPos, 16);
impl MatcherPos {
+1 -1
View File
@@ -3786,7 +3786,7 @@ pub fn fn_kind(self) -> Option<FnKind<'hir>> {
}
// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
mod size_asserts {
use super::*;
// tidy-alphabetical-start
+1 -1
View File
@@ -400,7 +400,7 @@ enum Chunk {
}
// This type is used a lot. Make sure it doesn't unintentionally get bigger.
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
crate::static_assert_size!(Chunk, 16);
impl<T> ChunkedBitSet<T> {
+1 -1
View File
@@ -477,7 +477,7 @@ pub enum SubregionOrigin<'tcx> {
}
// `SubregionOrigin` is used a lot. Make sure it doesn't unintentionally get bigger.
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
static_assert_size!(SubregionOrigin<'_>, 32);
impl<'tcx> SubregionOrigin<'tcx> {
+1 -1
View File
@@ -32,7 +32,7 @@
#[macro_use]
extern crate rustc_macros;
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
#[macro_use]
extern crate rustc_data_structures;
#[macro_use]
+1 -1
View File
@@ -112,7 +112,7 @@ pub fn derived_cause(
}
// `PredicateObligation` is used a lot. Make sure it doesn't unintentionally get bigger.
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
static_assert_size!(PredicateObligation<'_>, 48);
pub type PredicateObligations<'tcx> = Vec<PredicateObligation<'tcx>>;
+1 -1
View File
@@ -70,7 +70,7 @@ pub enum ConstValue<'tcx> {
},
}
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
static_assert_size!(ConstValue<'_>, 24);
impl<'tcx> ConstValue<'tcx> {
@@ -88,7 +88,7 @@ fn into(self) -> ErrorGuaranteed {
/// This is needed in `thir::pattern::lower_inline_const`.
pub type EvalToValTreeResult<'tcx> = Result<Option<ValTree<'tcx>>, ErrorHandled>;
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
static_assert_size!(InterpErrorInfo<'_>, 8);
/// Packages the kind of error we got from the const code interpreter
@@ -37,7 +37,7 @@ pub enum Scalar<Prov = CtfeProvenance> {
Ptr(Pointer<Prov>, u8),
}
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
static_assert_size!(Scalar, 24);
// We want the `Debug` output to be readable as it is used by `derive(Debug)` for
+1 -1
View File
@@ -1814,7 +1814,7 @@ pub fn dominates(self, location: Location, dominators: &Dominators<BasicBlock>)
}
// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
mod size_asserts {
use super::*;
use rustc_data_structures::static_assert_size;
+1 -1
View File
@@ -213,7 +213,7 @@ pub struct ClosureOutlivesRequirement<'tcx> {
}
// Make sure this enum doesn't unintentionally grow
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
rustc_data_structures::static_assert_size!(ConstraintCategory<'_>, 16);
/// Outlives-constraints can be categorized to determine whether and why they
+1 -1
View File
@@ -1453,7 +1453,7 @@ pub enum BinOp {
}
// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
mod size_asserts {
use super::*;
// tidy-alphabetical-start
+1 -1
View File
@@ -14,7 +14,7 @@ pub struct PlaceTy<'tcx> {
}
// At least on 64 bit systems, `PlaceTy` should not be larger than two or three pointers.
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
static_assert_size!(PlaceTy<'_>, 16);
impl<'tcx> PlaceTy<'tcx> {
+2 -2
View File
@@ -322,7 +322,7 @@ pub fn provided_to_erased<'tcx>(
// Ensure that keys grow no larger than 72 bytes by accident.
// Increase this limit if necessary, but do try to keep the size low if possible
#[cfg(all(any(target_arch = "x86_64", target_arch="aarch64"), target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
const _: () = {
if mem::size_of::<Key<'static>>() > 72 {
panic!("{}", concat!(
@@ -337,7 +337,7 @@ pub fn provided_to_erased<'tcx>(
// Ensure that values grow no larger than 64 bytes by accident.
// Increase this limit if necessary, but do try to keep the size low if possible
#[cfg(all(any(target_arch = "x86_64", target_arch="aarch64"), target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
const _: () = {
if mem::size_of::<Value<'static>>() > 64 {
panic!("{}", concat!(
+1 -1
View File
@@ -1206,7 +1206,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
}
// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
mod size_asserts {
use super::*;
// tidy-alphabetical-start
+1 -1
View File
@@ -550,7 +550,7 @@ pub fn peel_match_impls(&self) -> &Self {
}
// `ObligationCauseCode` is used a lot. Make sure it doesn't unintentionally get bigger.
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
static_assert_size!(ObligationCauseCode<'_>, 48);
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
+4 -1
View File
@@ -22,6 +22,9 @@
pub type ConstKind<'tcx> = IrConstKind<TyCtxt<'tcx>>;
#[cfg(target_pointer_width = "64")]
static_assert_size!(ConstKind<'_>, 32);
/// Use this rather than `ConstData`, whenever possible.
#[derive(Copy, Clone, PartialEq, Eq, Hash, HashStable)]
#[rustc_pass_by_value]
@@ -59,7 +62,7 @@ pub struct ConstData<'tcx> {
pub kind: ConstKind<'tcx>,
}
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
static_assert_size!(ConstData<'_>, 40);
impl<'tcx> Const<'tcx> {
+1 -4
View File
@@ -71,8 +71,5 @@ pub enum Expr<'tcx> {
Cast(CastKind, Const<'tcx>, Ty<'tcx>),
}
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
static_assert_size!(Expr<'_>, 24);
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
static_assert_size!(super::ConstKind<'_>, 32);
+1 -1
View File
@@ -2183,7 +2183,7 @@ pub struct DestructuredConst<'tcx> {
}
// Some types are used a lot. Make sure they don't unintentionally get bigger.
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
mod size_asserts {
use super::*;
use rustc_data_structures::static_assert_size;
+1 -1
View File
@@ -2697,7 +2697,7 @@ pub fn xform(self, other: VarianceDiagInfo<'tcx>) -> VarianceDiagInfo<'tcx> {
}
// Some types are used a lot. Make sure they don't unintentionally get bigger.
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
mod size_asserts {
use super::*;
use rustc_data_structures::static_assert_size;
+1 -1
View File
@@ -30,7 +30,7 @@
//
// This assertion is in this crate, rather than in `rustc_lexer`, because that
// crate cannot depend on `rustc_data_structures`.
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
rustc_data_structures::static_assert_size!(rustc_lexer::Token, 12);
#[derive(Clone, Debug)]
@@ -454,7 +454,7 @@ struct FrameData {
}
// Some types are used a lot. Make sure they don't unintentionally get bigger.
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
mod size_asserts {
use super::*;
use rustc_data_structures::static_assert_size;
+1 -1
View File
@@ -179,7 +179,7 @@ pub struct Parser<'a> {
// This type is used a lot, e.g. it's cloned when matching many declarative macro rules with nonterminals. Make sure
// it doesn't unintentionally get bigger.
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
rustc_data_structures::static_assert_size!(Parser<'_>, 264);
/// Stores span information about a closure.
+1 -1
View File
@@ -1087,7 +1087,7 @@ fn unescape_string(string: &str) -> Option<string::String> {
}
// Assert a reasonable size for `Piece`
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
rustc_index::static_assert_size!(Piece<'_>, 16);
#[cfg(test)]
+1 -1
View File
@@ -947,7 +947,7 @@ fn from_str(s: &str) -> Result<Self, Self::Err> {
}
// Some types are used a lot. Make sure they don't unintentionally get bigger.
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
mod size_asserts {
use super::*;
use rustc_data_structures::static_assert_size;
+1 -1
View File
@@ -31,7 +31,7 @@
#[macro_use]
extern crate rustc_macros;
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
#[macro_use]
extern crate rustc_data_structures;
#[macro_use]
@@ -72,7 +72,7 @@ pub struct PendingPredicateObligation<'tcx> {
}
// `PendingPredicateObligation` is used a lot. Make sure it doesn't unintentionally get bigger.
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
static_assert_size!(PendingPredicateObligation<'_>, 72);
impl<'tcx> FulfillmentContext<'tcx> {
+1 -1
View File
@@ -2567,7 +2567,7 @@ pub(crate) enum TypeBindingKind {
}
// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
mod size_asserts {
use super::*;
use rustc_data_structures::static_assert_size;
+3 -1
View File
@@ -78,8 +78,10 @@ pub(crate) struct Context<'tcx> {
}
// `Context` is cloned a lot, so we don't want the size to grow unexpectedly.
#[cfg(all(not(windows), target_arch = "x86_64", target_pointer_width = "64"))]
#[cfg(all(not(windows), target_pointer_width = "64"))]
rustc_data_structures::static_assert_size!(Context<'_>, 160);
#[cfg(all(windows, target_pointer_width = "64"))]
rustc_data_structures::static_assert_size!(Context<'_>, 168);
/// Shared mutable state used in [`Context`] and elsewhere.
pub(crate) struct SharedContext<'tcx> {
+3 -3
View File
@@ -241,12 +241,12 @@ pub enum ProvenanceExtra {
Wildcard,
}
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
static_assert_size!(Pointer<Provenance>, 24);
// FIXME: this would with in 24bytes but layout optimizations are not smart enough
// #[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
// #[cfg(target_pointer_width = "64")]
//static_assert_size!(Pointer<Option<Provenance>>, 24);
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
static_assert_size!(Scalar<Provenance>, 32);
impl fmt::Debug for Provenance {