Skip to content

Commit 4332498

Browse files
authored
Rollup merge of rust-lang#123401 - Zalathar:assert-size-aarch64, r=fmease
Check `x86_64` size assertions on `aarch64`, too (Context: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Checking.20size.20assertions.20on.20aarch64.3F) Currently the compiler has around 30 sets of `static_assert_size!` for various size-critical data structures (e.g. various IR nodes), guarded by `#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]`. (Presumably this cfg avoids having to maintain separate size values for 32-bit targets and unusual 64-bit targets. Apparently it may have been necessary before the i128/u128 alignment changes, too.) This is slightly incovenient for people on aarch64 workstations (e.g. Macs), because the assertions normally aren't checked until we push to a PR. So this PR adds `aarch64` to the `#[cfg(..)]` guarding all of those assertions in the compiler. --- Implemented with a simple find/replace. Verified by manually inspecting each `static_assert_size!` in `compiler/`, and checking that either the replacement succeeded, or adding aarch64 wouldn't have been appropriate.
2 parents 819568a + 2d47cd7 commit 4332498

File tree

33 files changed

+36
-36
lines changed

33 files changed

+36
-36
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3342,7 +3342,7 @@ impl TryFrom<ItemKind> for ForeignItemKind {
33423342
pub type ForeignItem = Item<ForeignItemKind>;
33433343

33443344
// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
3345-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
3345+
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
33463346
mod size_asserts {
33473347
use super::*;
33483348
use rustc_data_structures::static_assert_size;

compiler/rustc_ast/src/token.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ where
10211021
}
10221022

10231023
// Some types are used a lot. Make sure they don't unintentionally get bigger.
1024-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
1024+
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
10251025
mod size_asserts {
10261026
use super::*;
10271027
use rustc_data_structures::static_assert_size;

compiler/rustc_ast/src/tokenstream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ impl DelimSpacing {
768768
}
769769

770770
// Some types are used a lot. Make sure they don't unintentionally get bigger.
771-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
771+
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
772772
mod size_asserts {
773773
use super::*;
774774
use rustc_data_structures::static_assert_size;

compiler/rustc_const_eval/src/interpret/operand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
792792
}
793793

794794
// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
795-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
795+
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
796796
mod size_asserts {
797797
use super::*;
798798
use rustc_data_structures::static_assert_size;

compiler/rustc_const_eval/src/interpret/place.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ where
10581058
}
10591059

10601060
// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
1061-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
1061+
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
10621062
mod size_asserts {
10631063
use super::*;
10641064
use rustc_data_structures::static_assert_size;

compiler/rustc_errors/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ pub type PResult<'a, T> = Result<T, PErr<'a>>;
102102
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
103103

104104
// `PResult` is used a lot. Make sure it doesn't unintentionally get bigger.
105-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
105+
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
106106
rustc_data_structures::static_assert_size!(PResult<'_, ()>, 16);
107-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
107+
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
108108
rustc_data_structures::static_assert_size!(PResult<'_, bool>, 16);
109109

110110
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, Encodable, Decodable)]

compiler/rustc_expand/src/mbe/macro_parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ struct MatcherPos {
266266
}
267267

268268
// This type is used a lot. Make sure it doesn't unintentionally get bigger.
269-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
269+
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
270270
rustc_data_structures::static_assert_size!(MatcherPos, 16);
271271

272272
impl MatcherPos {

compiler/rustc_hir/src/hir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3761,7 +3761,7 @@ impl<'hir> Node<'hir> {
37613761
}
37623762

37633763
// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
3764-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
3764+
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
37653765
mod size_asserts {
37663766
use super::*;
37673767
// tidy-alphabetical-start

compiler/rustc_index/src/bit_set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ enum Chunk {
400400
}
401401

402402
// This type is used a lot. Make sure it doesn't unintentionally get bigger.
403-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
403+
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
404404
crate::static_assert_size!(Chunk, 16);
405405

406406
impl<T> ChunkedBitSet<T> {

compiler/rustc_infer/src/infer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ pub enum SubregionOrigin<'tcx> {
483483
}
484484

485485
// `SubregionOrigin` is used a lot. Make sure it doesn't unintentionally get bigger.
486-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
486+
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
487487
static_assert_size!(SubregionOrigin<'_>, 32);
488488

489489
impl<'tcx> SubregionOrigin<'tcx> {

0 commit comments

Comments
 (0)