Skip to content

Commit c25473f

Browse files
committed
Auto merge of rust-lang#124008 - nnethercote:simpler-static_assert_size, r=Nilstrieb
Simplify `static_assert_size`s. We want to run them on all 64-bit platforms. r? `@ghost`
2 parents ecd4547 + 0d97669 commit c25473f

File tree

36 files changed

+45
-43
lines changed

36 files changed

+45
-43
lines changed

compiler/rustc_ast/src/ast.rs

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

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

compiler/rustc_ast/src/token.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ where
10231023
}
10241024

10251025
// Some types are used a lot. Make sure they don't unintentionally get bigger.
1026-
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
1026+
#[cfg(target_pointer_width = "64")]
10271027
mod size_asserts {
10281028
use super::*;
10291029
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(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
771+
#[cfg(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(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
795+
#[cfg(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(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
1061+
#[cfg(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(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
105+
#[cfg(target_pointer_width = "64")]
106106
rustc_data_structures::static_assert_size!(PResult<'_, ()>, 16);
107-
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
107+
#[cfg(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(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
269+
#[cfg(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
@@ -3786,7 +3786,7 @@ impl<'hir> Node<'hir> {
37863786
}
37873787

37883788
// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
3789-
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
3789+
#[cfg(target_pointer_width = "64")]
37903790
mod size_asserts {
37913791
use super::*;
37923792
// 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(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
403+
#[cfg(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
@@ -477,7 +477,7 @@ pub enum SubregionOrigin<'tcx> {
477477
}
478478

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

483483
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(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
35+
#[cfg(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(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
115+
#[cfg(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(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
73+
#[cfg(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(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
91+
#[cfg(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(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
40+
#[cfg(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
@@ -1813,7 +1813,7 @@ impl DefLocation {
18131813
}
18141814

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

compiler/rustc_middle/src/mir/query.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ pub struct ClosureOutlivesRequirement<'tcx> {
213213
}
214214

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

219219
/// 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(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
1456+
#[cfg(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(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
17+
#[cfg(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
@@ -322,7 +322,7 @@ macro_rules! define_callbacks {
322322

323323
// Ensure that keys grow no larger than 72 bytes by accident.
324324
// Increase this limit if necessary, but do try to keep the size low if possible
325-
#[cfg(all(any(target_arch = "x86_64", target_arch="aarch64"), target_pointer_width = "64"))]
325+
#[cfg(target_pointer_width = "64")]
326326
const _: () = {
327327
if mem::size_of::<Key<'static>>() > 72 {
328328
panic!("{}", concat!(
@@ -337,7 +337,7 @@ macro_rules! define_callbacks {
337337

338338
// Ensure that values grow no larger than 64 bytes by accident.
339339
// Increase this limit if necessary, but do try to keep the size low if possible
340-
#[cfg(all(any(target_arch = "x86_64", target_arch="aarch64"), target_pointer_width = "64"))]
340+
#[cfg(target_pointer_width = "64")]
341341
const _: () = {
342342
if mem::size_of::<Value<'static>>() > 64 {
343343
panic!("{}", concat!(

compiler/rustc_middle/src/thir.rs

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

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

compiler/rustc_middle/src/traits/mod.rs

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

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

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

compiler/rustc_middle/src/ty/consts.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ pub use valtree::*;
2222

2323
pub type ConstKind<'tcx> = IrConstKind<TyCtxt<'tcx>>;
2424

25+
#[cfg(target_pointer_width = "64")]
26+
static_assert_size!(ConstKind<'_>, 32);
27+
2528
/// Use this rather than `ConstData`, whenever possible.
2629
#[derive(Copy, Clone, PartialEq, Eq, Hash, HashStable)]
2730
#[rustc_pass_by_value]
@@ -59,7 +62,7 @@ pub struct ConstData<'tcx> {
5962
pub kind: ConstKind<'tcx>,
6063
}
6164

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

6568
impl<'tcx> Const<'tcx> {

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

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

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

compiler/rustc_middle/src/ty/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2183,7 +2183,7 @@ pub struct DestructuredConst<'tcx> {
21832183
}
21842184

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

compiler/rustc_middle/src/ty/sty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2697,7 +2697,7 @@ impl<'tcx> VarianceDiagInfo<'tcx> {
26972697
}
26982698

26992699
// Some types are used a lot. Make sure they don't unintentionally get bigger.
2700-
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
2700+
#[cfg(target_pointer_width = "64")]
27012701
mod size_asserts {
27022702
use super::*;
27032703
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(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
33+
#[cfg(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(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
457+
#[cfg(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(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
182+
#[cfg(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(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
1090+
#[cfg(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
@@ -947,7 +947,7 @@ impl FromStr for Conv {
947947
}
948948

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

compiler/rustc_trait_selection/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
#[macro_use]
3333
extern crate rustc_macros;
34-
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
34+
#[cfg(target_pointer_width = "64")]
3535
#[macro_use]
3636
extern crate rustc_data_structures;
3737
#[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(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
75+
#[cfg(target_pointer_width = "64")]
7676
static_assert_size!(PendingPredicateObligation<'_>, 72);
7777

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

src/librustdoc/clean/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2567,7 +2567,7 @@ pub(crate) enum TypeBindingKind {
25672567
}
25682568

25692569
// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
2570-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
2570+
#[cfg(target_pointer_width = "64")]
25712571
mod size_asserts {
25722572
use super::*;
25732573
use rustc_data_structures::static_assert_size;

src/librustdoc/html/render/context.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,10 @@ pub(crate) struct Context<'tcx> {
7878
}
7979

8080
// `Context` is cloned a lot, so we don't want the size to grow unexpectedly.
81-
#[cfg(all(not(windows), target_arch = "x86_64", target_pointer_width = "64"))]
81+
#[cfg(all(not(windows), target_pointer_width = "64"))]
8282
rustc_data_structures::static_assert_size!(Context<'_>, 160);
83+
#[cfg(all(windows, target_pointer_width = "64"))]
84+
rustc_data_structures::static_assert_size!(Context<'_>, 168);
8385

8486
/// Shared mutable state used in [`Context`] and elsewhere.
8587
pub(crate) struct SharedContext<'tcx> {

src/tools/miri/src/machine.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,12 @@ pub enum ProvenanceExtra {
241241
Wildcard,
242242
}
243243

244-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
244+
#[cfg(target_pointer_width = "64")]
245245
static_assert_size!(Pointer<Provenance>, 24);
246246
// FIXME: this would with in 24bytes but layout optimizations are not smart enough
247-
// #[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
247+
// #[cfg(target_pointer_width = "64")]
248248
//static_assert_size!(Pointer<Option<Provenance>>, 24);
249-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
249+
#[cfg(target_pointer_width = "64")]
250250
static_assert_size!(Scalar<Provenance>, 32);
251251

252252
impl fmt::Debug for Provenance {

0 commit comments

Comments
 (0)