Skip to content

Commit 95e096d

Browse files
committed
Change x64 size checks to not apply to x32.
Rust contains various size checks conditional on target_arch = "x86_64", but these checks were never intended to apply to x86_64-unknown-linux-gnux32. Add target_pointer_width = "64" to the conditions.
1 parent 51748a8 commit 95e096d

File tree

23 files changed

+39
-39
lines changed

23 files changed

+39
-39
lines changed

compiler/rustc_ast/src/ast.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,7 @@ pub struct Expr {
10831083
}
10841084

10851085
// `Expr` is used a lot. Make sure it doesn't unintentionally get bigger.
1086-
#[cfg(target_arch = "x86_64")]
1086+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
10871087
rustc_data_structures::static_assert_size!(Expr, 120);
10881088

10891089
impl Expr {
@@ -2757,7 +2757,7 @@ pub enum ItemKind {
27572757
MacroDef(MacroDef),
27582758
}
27592759

2760-
#[cfg(target_arch = "x86_64")]
2760+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
27612761
rustc_data_structures::static_assert_size!(ItemKind, 112);
27622762

27632763
impl ItemKind {
@@ -2831,7 +2831,7 @@ pub enum AssocItemKind {
28312831
MacCall(MacCall),
28322832
}
28332833

2834-
#[cfg(target_arch = "x86_64")]
2834+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
28352835
rustc_data_structures::static_assert_size!(AssocItemKind, 72);
28362836

28372837
impl AssocItemKind {
@@ -2883,7 +2883,7 @@ pub enum ForeignItemKind {
28832883
MacCall(MacCall),
28842884
}
28852885

2886-
#[cfg(target_arch = "x86_64")]
2886+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
28872887
rustc_data_structures::static_assert_size!(ForeignItemKind, 72);
28882888

28892889
impl From<ForeignItemKind> for ItemKind {

compiler/rustc_ast/src/token.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ pub enum TokenKind {
244244
}
245245

246246
// `TokenKind` is used a lot. Make sure it doesn't unintentionally get bigger.
247-
#[cfg(target_arch = "x86_64")]
247+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
248248
rustc_data_structures::static_assert_size!(TokenKind, 16);
249249

250250
#[derive(Clone, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)]
@@ -682,7 +682,7 @@ pub enum Nonterminal {
682682
}
683683

684684
// `Nonterminal` is used a lot. Make sure it doesn't unintentionally get bigger.
685-
#[cfg(target_arch = "x86_64")]
685+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
686686
rustc_data_structures::static_assert_size!(Nonterminal, 48);
687687

688688
#[derive(Debug, Copy, Clone, PartialEq, Encodable, Decodable)]

compiler/rustc_ast/src/tokenstream.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ pub struct TokenStream(pub(crate) Lrc<Vec<TreeAndSpacing>>);
189189
pub type TreeAndSpacing = (TokenTree, Spacing);
190190

191191
// `TokenStream` is used a lot. Make sure it doesn't unintentionally get bigger.
192-
#[cfg(target_arch = "x86_64")]
192+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
193193
rustc_data_structures::static_assert_size!(TokenStream, 8);
194194

195195
#[derive(Clone, Copy, Debug, PartialEq, Encodable, Decodable)]

compiler/rustc_errors/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub type PResult<'a, T> = Result<T, DiagnosticBuilder<'a>>;
5252

5353
// `PResult` is used a lot. Make sure it doesn't unintentionally get bigger.
5454
// (See also the comment on `DiagnosticBuilderInner`.)
55-
#[cfg(target_arch = "x86_64")]
55+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
5656
rustc_data_structures::static_assert_size!(PResult<'_, bool>, 16);
5757

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

compiler/rustc_hir/src/hir.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3088,7 +3088,7 @@ impl<'hir> Node<'hir> {
30883088
}
30893089

30903090
// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
3091-
#[cfg(target_arch = "x86_64")]
3091+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
30923092
mod size_asserts {
30933093
rustc_data_structures::static_assert_size!(super::Block<'static>, 48);
30943094
rustc_data_structures::static_assert_size!(super::Expr<'static>, 72);

compiler/rustc_infer/src/infer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ pub enum SubregionOrigin<'tcx> {
408408
}
409409

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

414414
/// Times when we replace late-bound regions with variables:

compiler/rustc_infer/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
#[macro_use]
2929
extern crate rustc_macros;
30-
#[cfg(target_arch = "x86_64")]
30+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
3131
#[macro_use]
3232
extern crate rustc_data_structures;
3333
#[macro_use]

compiler/rustc_infer/src/traits/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub type PredicateObligation<'tcx> = Obligation<'tcx, ty::Predicate<'tcx>>;
5656
pub type TraitObligation<'tcx> = Obligation<'tcx, ty::PolyTraitPredicate<'tcx>>;
5757

5858
// `PredicateObligation` is used a lot. Make sure it doesn't unintentionally get bigger.
59-
#[cfg(target_arch = "x86_64")]
59+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
6060
static_assert_size!(PredicateObligation<'_>, 32);
6161

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

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub fn struct_error<'tcx>(tcx: TyCtxtAt<'tcx>, msg: &str) -> DiagnosticBuilder<'
4040
struct_span_err!(tcx.sess, tcx.span, E0080, "{}", msg)
4141
}
4242

43-
#[cfg(target_arch = "x86_64")]
43+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
4444
static_assert_size!(InterpErrorInfo<'_>, 8);
4545

4646
/// Packages the kind of error we got from the const code interpreter
@@ -444,7 +444,7 @@ impl dyn MachineStopType {
444444
}
445445
}
446446

447-
#[cfg(target_arch = "x86_64")]
447+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
448448
static_assert_size!(InterpError<'_>, 72);
449449

450450
pub enum InterpError<'tcx> {

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub enum ConstValue<'tcx> {
4444
},
4545
}
4646

47-
#[cfg(target_arch = "x86_64")]
47+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
4848
static_assert_size!(ConstValue<'_>, 32);
4949

5050
impl<'tcx> ConstValue<'tcx> {
@@ -111,7 +111,7 @@ pub enum Scalar<Tag = ()> {
111111
Ptr(Pointer<Tag>),
112112
}
113113

114-
#[cfg(target_arch = "x86_64")]
114+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
115115
static_assert_size!(Scalar, 24);
116116

117117
// We want the `Debug` output to be readable as it is used by `derive(Debug)` for
@@ -509,7 +509,7 @@ pub enum ScalarMaybeUninit<Tag = ()> {
509509
Uninit,
510510
}
511511

512-
#[cfg(target_arch = "x86_64")]
512+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
513513
static_assert_size!(ScalarMaybeUninit, 24);
514514

515515
impl<Tag> From<Scalar<Tag>> for ScalarMaybeUninit<Tag> {

compiler/rustc_middle/src/mir/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ pub struct LocalDecl<'tcx> {
951951
}
952952

953953
// `LocalDecl` is used a lot. Make sure it doesn't unintentionally get bigger.
954-
#[cfg(target_arch = "x86_64")]
954+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
955955
static_assert_size!(LocalDecl<'_>, 56);
956956

957957
/// Extra information about a some locals that's used for diagnostics and for
@@ -1468,7 +1468,7 @@ pub struct Statement<'tcx> {
14681468
}
14691469

14701470
// `Statement` is used a lot. Make sure it doesn't unintentionally get bigger.
1471-
#[cfg(target_arch = "x86_64")]
1471+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
14721472
static_assert_size!(Statement<'_>, 32);
14731473

14741474
impl Statement<'_> {
@@ -1752,7 +1752,7 @@ impl<V, T> ProjectionElem<V, T> {
17521752
pub type PlaceElem<'tcx> = ProjectionElem<Local, Ty<'tcx>>;
17531753

17541754
// At least on 64 bit systems, `PlaceElem` should not be larger than two pointers.
1755-
#[cfg(target_arch = "x86_64")]
1755+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
17561756
static_assert_size!(PlaceElem<'_>, 24);
17571757

17581758
/// Alias for projections as they appear in `UserTypeProjection`, where we

compiler/rustc_middle/src/mir/tcx.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub struct PlaceTy<'tcx> {
1717
}
1818

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

2323
impl<'tcx> PlaceTy<'tcx> {

compiler/rustc_middle/src/traits/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ impl ObligationCauseCode<'_> {
340340
}
341341

342342
// `ObligationCauseCode` is used a lot. Make sure it doesn't unintentionally get bigger.
343-
#[cfg(target_arch = "x86_64")]
343+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
344344
static_assert_size!(ObligationCauseCode<'_>, 32);
345345

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

compiler/rustc_middle/src/ty/consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub struct Const<'tcx> {
2323
pub val: ConstKind<'tcx>,
2424
}
2525

26-
#[cfg(target_arch = "x86_64")]
26+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
2727
static_assert_size!(Const<'_>, 48);
2828

2929
impl<'tcx> Const<'tcx> {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub enum ConstKind<'tcx> {
3737
Error(ty::DelaySpanBugEmitted),
3838
}
3939

40-
#[cfg(target_arch = "x86_64")]
40+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
4141
static_assert_size!(ConstKind<'_>, 40);
4242

4343
impl<'tcx> ConstKind<'tcx> {

compiler/rustc_middle/src/ty/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ impl<'tcx> TyS<'tcx> {
483483
}
484484

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

489489
impl<'tcx> Ord for TyS<'tcx> {
@@ -1030,7 +1030,7 @@ crate struct PredicateInner<'tcx> {
10301030
outer_exclusive_binder: ty::DebruijnIndex,
10311031
}
10321032

1033-
#[cfg(target_arch = "x86_64")]
1033+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
10341034
static_assert_size!(PredicateInner<'_>, 40);
10351035

10361036
#[derive(Clone, Copy, Lift)]

compiler/rustc_middle/src/ty/sty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ impl TyKind<'tcx> {
231231
}
232232

233233
// `TyKind` is used a lot. Make sure it doesn't unintentionally get bigger.
234-
#[cfg(target_arch = "x86_64")]
234+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
235235
static_assert_size!(TyKind<'_>, 24);
236236

237237
/// A closure can be modeled as a struct that looks like:

compiler/rustc_mir/src/interpret/operand.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub enum Immediate<Tag = ()> {
3232
ScalarPair(ScalarMaybeUninit<Tag>, ScalarMaybeUninit<Tag>),
3333
}
3434

35-
#[cfg(target_arch = "x86_64")]
35+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
3636
rustc_data_structures::static_assert_size!(Immediate, 56);
3737

3838
impl<Tag> From<ScalarMaybeUninit<Tag>> for Immediate<Tag> {
@@ -95,7 +95,7 @@ pub struct ImmTy<'tcx, Tag = ()> {
9595
pub layout: TyAndLayout<'tcx>,
9696
}
9797

98-
#[cfg(target_arch = "x86_64")]
98+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
9999
rustc_data_structures::static_assert_size!(ImmTy<'_>, 72);
100100

101101
impl<Tag: Copy> std::fmt::Display for ImmTy<'tcx, Tag> {
@@ -162,7 +162,7 @@ pub struct OpTy<'tcx, Tag = ()> {
162162
pub layout: TyAndLayout<'tcx>,
163163
}
164164

165-
#[cfg(target_arch = "x86_64")]
165+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
166166
rustc_data_structures::static_assert_size!(OpTy<'_, ()>, 80);
167167

168168
impl<'tcx, Tag> std::ops::Deref for OpTy<'tcx, Tag> {

compiler/rustc_mir/src/interpret/place.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub enum MemPlaceMeta<Tag = ()> {
3333
Poison,
3434
}
3535

36-
#[cfg(target_arch = "x86_64")]
36+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
3737
rustc_data_structures::static_assert_size!(MemPlaceMeta, 24);
3838

3939
impl<Tag> MemPlaceMeta<Tag> {
@@ -74,7 +74,7 @@ pub struct MemPlace<Tag = ()> {
7474
pub meta: MemPlaceMeta<Tag>,
7575
}
7676

77-
#[cfg(target_arch = "x86_64")]
77+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
7878
rustc_data_structures::static_assert_size!(MemPlace, 56);
7979

8080
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable)]
@@ -87,7 +87,7 @@ pub enum Place<Tag = ()> {
8787
Local { frame: usize, local: mir::Local },
8888
}
8989

90-
#[cfg(target_arch = "x86_64")]
90+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
9191
rustc_data_structures::static_assert_size!(Place, 64);
9292

9393
#[derive(Copy, Clone, Debug)]
@@ -96,7 +96,7 @@ pub struct PlaceTy<'tcx, Tag = ()> {
9696
pub layout: TyAndLayout<'tcx>,
9797
}
9898

99-
#[cfg(target_arch = "x86_64")]
99+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
100100
rustc_data_structures::static_assert_size!(PlaceTy<'_>, 80);
101101

102102
impl<'tcx, Tag> std::ops::Deref for PlaceTy<'tcx, Tag> {
@@ -114,7 +114,7 @@ pub struct MPlaceTy<'tcx, Tag = ()> {
114114
pub layout: TyAndLayout<'tcx>,
115115
}
116116

117-
#[cfg(target_arch = "x86_64")]
117+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
118118
rustc_data_structures::static_assert_size!(MPlaceTy<'_>, 72);
119119

120120
impl<'tcx, Tag> std::ops::Deref for MPlaceTy<'tcx, Tag> {

compiler/rustc_mir_build/src/thir/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ crate enum StmtKind<'tcx> {
9696
}
9797

9898
// `Expr` is used a lot. Make sure it doesn't unintentionally get bigger.
99-
#[cfg(target_arch = "x86_64")]
99+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
100100
rustc_data_structures::static_assert_size!(Expr<'_>, 168);
101101

102102
/// The Thir trait implementor lowers their expressions (`&'tcx H::Expr`)

compiler/rustc_trait_selection/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
#[macro_use]
2525
extern crate rustc_macros;
26-
#[cfg(target_arch = "x86_64")]
26+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
2727
#[macro_use]
2828
extern crate rustc_data_structures;
2929
#[macro_use]

compiler/rustc_trait_selection/src/traits/fulfill.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ pub struct PendingPredicateObligation<'tcx> {
8787
}
8888

8989
// `PendingPredicateObligation` is used a lot. Make sure it doesn't unintentionally get bigger.
90-
#[cfg(target_arch = "x86_64")]
90+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
9191
static_assert_size!(PendingPredicateObligation<'_>, 56);
9292

9393
impl<'a, 'tcx> FulfillmentContext<'tcx> {

src/librustdoc/clean/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ crate struct Item {
9393
}
9494

9595
// `Item` is used a lot. Make sure it doesn't unintentionally get bigger.
96-
#[cfg(target_arch = "x86_64")]
96+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
9797
rustc_data_structures::static_assert_size!(Item, 48);
9898

9999
impl fmt::Debug for Item {

0 commit comments

Comments
 (0)