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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 3 additions & 3 deletions
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> {

0 commit comments

Comments
 (0)