Skip to content

Commit 2d47cd7

Browse files
committed
Check x86_64 size assertions on aarch64, too
This makes it easier for contributors on aarch64 workstations (e.g. Macs) to notice when these assertions have been violated.
1 parent b688d53 commit 2d47cd7

File tree

33 files changed

+36
-36
lines changed

33 files changed

+36
-36
lines changed

compiler/rustc_ast/src/ast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3341,7 +3341,7 @@ impl TryFrom<ItemKind> for ForeignItemKind {
33413341
pub type ForeignItem = Item<ForeignItemKind>;
33423342

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

compiler/rustc_ast/src/token.rs

+1-1
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

+1-1
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

+1-1
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

+1-1
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

+2-2
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

+1-1
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -3762,7 +3762,7 @@ impl<'hir> Node<'hir> {
37623762
}
37633763

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

compiler/rustc_index/src/bit_set.rs

+1-1
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

+1-1
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> {

compiler/rustc_infer/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
#[macro_use]
3434
extern crate rustc_macros;
35-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
35+
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
3636
#[macro_use]
3737
extern crate rustc_data_structures;
3838
#[macro_use]

compiler/rustc_infer/src/traits/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ impl<'tcx> PolyTraitObligation<'tcx> {
112112
}
113113

114114
// `PredicateObligation` is used a lot. Make sure it doesn't unintentionally get bigger.
115-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
115+
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
116116
static_assert_size!(PredicateObligation<'_>, 48);
117117

118118
pub type PredicateObligations<'tcx> = Vec<PredicateObligation<'tcx>>;

compiler/rustc_middle/src/mir/consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pub enum ConstValue<'tcx> {
7070
},
7171
}
7272

73-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
73+
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
7474
static_assert_size!(ConstValue<'_>, 24);
7575

7676
impl<'tcx> ConstValue<'tcx> {

compiler/rustc_middle/src/mir/interpret/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ pub type EvalToConstValueResult<'tcx> = Result<ConstValue<'tcx>, ErrorHandled>;
8888
/// This is needed in `thir::pattern::lower_inline_const`.
8989
pub type EvalToValTreeResult<'tcx> = Result<Option<ValTree<'tcx>>, ErrorHandled>;
9090

91-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
91+
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
9292
static_assert_size!(InterpErrorInfo<'_>, 8);
9393

9494
/// Packages the kind of error we got from the const code interpreter

compiler/rustc_middle/src/mir/interpret/value.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub enum Scalar<Prov = CtfeProvenance> {
3737
Ptr(Pointer<Prov>, u8),
3838
}
3939

40-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
40+
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
4141
static_assert_size!(Scalar, 24);
4242

4343
// We want the `Debug` output to be readable as it is used by `derive(Debug)` for

compiler/rustc_middle/src/mir/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1881,7 +1881,7 @@ impl DefLocation {
18811881
}
18821882

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

compiler/rustc_middle/src/mir/query.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ pub struct ClosureOutlivesRequirement<'tcx> {
276276
}
277277

278278
// Make sure this enum doesn't unintentionally grow
279-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
279+
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
280280
rustc_data_structures::static_assert_size!(ConstraintCategory<'_>, 16);
281281

282282
/// Outlives-constraints can be categorized to determine whether and why they

compiler/rustc_middle/src/mir/syntax.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1453,7 +1453,7 @@ pub enum BinOp {
14531453
}
14541454

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

compiler/rustc_middle/src/mir/tcx.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub struct PlaceTy<'tcx> {
1414
}
1515

1616
// At least on 64 bit systems, `PlaceTy` should not be larger than two or three pointers.
17-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
17+
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
1818
static_assert_size!(PlaceTy<'_>, 16);
1919

2020
impl<'tcx> PlaceTy<'tcx> {

compiler/rustc_middle/src/query/plumbing.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ macro_rules! define_callbacks {
339339
pub type Storage<'tcx> = <$($K)* as keys::Key>::Cache<Erase<$V>>;
340340

341341
// Ensure that keys grow no larger than 64 bytes
342-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
342+
#[cfg(all(any(target_arch = "x86_64", target_arch="aarch64"), target_pointer_width = "64"))]
343343
const _: () = {
344344
if mem::size_of::<Key<'static>>() > 64 {
345345
panic!("{}", concat!(
@@ -353,7 +353,7 @@ macro_rules! define_callbacks {
353353
};
354354

355355
// Ensure that values grow no larger than 64 bytes
356-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
356+
#[cfg(all(any(target_arch = "x86_64", target_arch="aarch64"), target_pointer_width = "64"))]
357357
const _: () = {
358358
if mem::size_of::<Value<'static>>() > 64 {
359359
panic!("{}", concat!(

compiler/rustc_middle/src/thir.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,7 @@ impl<'tcx> fmt::Display for Pat<'tcx> {
12041204
}
12051205

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

compiler/rustc_middle/src/traits/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ impl<'tcx> ObligationCauseCode<'tcx> {
550550
}
551551

552552
// `ObligationCauseCode` is used a lot. Make sure it doesn't unintentionally get bigger.
553-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
553+
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
554554
static_assert_size!(ObligationCauseCode<'_>, 48);
555555

556556
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]

compiler/rustc_middle/src/ty/consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub struct ConstData<'tcx> {
5959
pub kind: ConstKind<'tcx>,
6060
}
6161

62-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
62+
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
6363
static_assert_size!(ConstData<'_>, 40);
6464

6565
impl<'tcx> Const<'tcx> {

compiler/rustc_middle/src/ty/consts/kind.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ pub enum Expr<'tcx> {
7171
Cast(CastKind, Const<'tcx>, Ty<'tcx>),
7272
}
7373

74-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
74+
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
7575
static_assert_size!(Expr<'_>, 24);
7676

77-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
77+
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
7878
static_assert_size!(super::ConstKind<'_>, 32);

compiler/rustc_middle/src/ty/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2168,7 +2168,7 @@ pub struct DestructuredConst<'tcx> {
21682168
}
21692169

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

compiler/rustc_middle/src/ty/sty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2699,7 +2699,7 @@ impl<'tcx> VarianceDiagInfo<'tcx> {
26992699
}
27002700

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

compiler/rustc_parse/src/lexer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use unescape_error_reporting::{emit_unescape_error, escaped_char};
3030
//
3131
// This assertion is in this crate, rather than in `rustc_lexer`, because that
3232
// crate cannot depend on `rustc_data_structures`.
33-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
33+
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
3434
rustc_data_structures::static_assert_size!(rustc_lexer::Token, 12);
3535

3636
#[derive(Clone, Debug)]

compiler/rustc_parse/src/parser/attr_wrapper.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ fn make_token_stream(
454454
}
455455

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

compiler/rustc_parse/src/parser/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ pub struct Parser<'a> {
179179

180180
// This type is used a lot, e.g. it's cloned when matching many declarative macro rules with nonterminals. Make sure
181181
// it doesn't unintentionally get bigger.
182-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
182+
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
183183
rustc_data_structures::static_assert_size!(Parser<'_>, 264);
184184

185185
/// Stores span information about a closure.

compiler/rustc_parse_format/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1087,7 +1087,7 @@ fn unescape_string(string: &str) -> Option<string::String> {
10871087
}
10881088

10891089
// Assert a reasonable size for `Piece`
1090-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
1090+
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
10911091
rustc_index::static_assert_size!(Piece<'_>, 16);
10921092

10931093
#[cfg(test)]

compiler/rustc_target/src/abi/call/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ impl FromStr for Conv {
927927
}
928928

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

compiler/rustc_trait_selection/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
#[macro_use]
3232
extern crate rustc_macros;
33-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
33+
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
3434
#[macro_use]
3535
extern crate rustc_data_structures;
3636
#[macro_use]

compiler/rustc_trait_selection/src/traits/fulfill.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ pub struct PendingPredicateObligation<'tcx> {
7272
}
7373

7474
// `PendingPredicateObligation` is used a lot. Make sure it doesn't unintentionally get bigger.
75-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
75+
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
7676
static_assert_size!(PendingPredicateObligation<'_>, 72);
7777

7878
impl<'tcx> FulfillmentContext<'tcx> {

0 commit comments

Comments
 (0)