Skip to content

Commit 2bd4d5b

Browse files
committed
Move two static_assert!s to better spots.
And make them x86_64-only so they can use `==` instead of `<=`.
1 parent fb3dd9f commit 2bd4d5b

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

src/librustc/ty/context.rs

-6
Original file line numberDiff line numberDiff line change
@@ -823,12 +823,6 @@ impl<'a, 'gcx> HashStable<StableHashingContext<'a>> for TypeckTables<'gcx> {
823823

824824
impl<'tcx> CommonTypes<'tcx> {
825825
fn new(interners: &CtxtInterners<'tcx>) -> CommonTypes<'tcx> {
826-
// Ensure our type representation does not grow
827-
#[cfg(target_pointer_width = "64")]
828-
static_assert!(ASSERT_TY_KIND: ::std::mem::size_of::<ty::TyKind<'_>>() <= 24);
829-
#[cfg(target_pointer_width = "64")]
830-
static_assert!(ASSERT_TYS: ::std::mem::size_of::<ty::TyS<'_>>() <= 32);
831-
832826
let mk = |sty| CtxtInterners::intern_ty(interners, interners, sty);
833827
let mk_region = |r| {
834828
if let Some(r) = interners.region.borrow().get(&r) {

src/librustc/ty/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,10 @@ pub struct TyS<'tcx> {
514514
outer_exclusive_binder: ty::DebruijnIndex,
515515
}
516516

517+
// `TyS` is used a lot. Make sure it doesn't unintentionally get bigger.
518+
#[cfg(target_arch = "x86_64")]
519+
static_assert!(MEM_SIZE_OF_TY_S: ::std::mem::size_of::<TyS<'_>>() == 32);
520+
517521
impl<'tcx> Ord for TyS<'tcx> {
518522
fn cmp(&self, other: &TyS<'tcx>) -> Ordering {
519523
self.sty.cmp(&other.sty)

src/librustc/ty/sty.rs

+4
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,10 @@ pub enum TyKind<'tcx> {
211211
Error,
212212
}
213213

214+
// `TyKind` is used a lot. Make sure it doesn't unintentionally get bigger.
215+
#[cfg(target_arch = "x86_64")]
216+
static_assert!(MEM_SIZE_OF_TY_KIND: ::std::mem::size_of::<TyKind<'_>>() == 24);
217+
214218
/// A closure can be modeled as a struct that looks like:
215219
///
216220
/// struct Closure<'l0...'li, T0...Tj, CK, CS, U0...Uk> {

src/libsyntax/ast.rs

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use print::pprust;
2020
use ptr::P;
2121
use rustc_data_structures::indexed_vec;
2222
use rustc_data_structures::indexed_vec::Idx;
23+
#[cfg(target_arch = "x86_64")]
2324
use rustc_data_structures::static_assert;
2425
use rustc_target::spec::abi::Abi;
2526
use source_map::{dummy_spanned, respan, Spanned};

0 commit comments

Comments
 (0)