Skip to content

Commit e01e0b0

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 e01e0b0

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

src/librustc/ty/context.rs

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

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

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

0 commit comments

Comments
 (0)