Skip to content

Commit 7aec38b

Browse files
committed
Fix up size asserts.
- Put them in the module that defines the type. - Add some `WithCachedTypeInfo<T>` asserts for consistency.
1 parent cf95e45 commit 7aec38b

File tree

4 files changed

+26
-14
lines changed

4 files changed

+26
-14
lines changed

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2238,15 +2238,3 @@ pub struct DestructuredConst<'tcx> {
22382238
pub variant: Option<VariantIdx>,
22392239
pub fields: &'tcx [ty::Const<'tcx>],
22402240
}
2241-
2242-
// Some types are used a lot. Make sure they don't unintentionally get bigger.
2243-
#[cfg(target_pointer_width = "64")]
2244-
mod size_asserts {
2245-
use rustc_data_structures::static_assert_size;
2246-
2247-
use super::*;
2248-
// tidy-alphabetical-start
2249-
static_assert_size!(PredicateKind<'_>, 32);
2250-
static_assert_size!(WithCachedTypeInfo<TyKind<'_>>, 48);
2251-
// tidy-alphabetical-end
2252-
}

compiler/rustc_middle/src/ty/predicate.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,3 +704,15 @@ impl<'tcx> Predicate<'tcx> {
704704
}
705705
}
706706
}
707+
708+
// Some types are used a lot. Make sure they don't unintentionally get bigger.
709+
#[cfg(target_pointer_width = "64")]
710+
mod size_asserts {
711+
use rustc_data_structures::static_assert_size;
712+
713+
use super::*;
714+
// tidy-alphabetical-start
715+
static_assert_size!(PredicateKind<'_>, 32);
716+
static_assert_size!(WithCachedTypeInfo<PredicateKind<'_>>, 56);
717+
// tidy-alphabetical-end
718+
}

compiler/rustc_middle/src/ty/region.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,3 +495,15 @@ impl BoundRegionKind {
495495
}
496496
}
497497
}
498+
499+
// Some types are used a lot. Make sure they don't unintentionally get bigger.
500+
#[cfg(target_pointer_width = "64")]
501+
mod size_asserts {
502+
use rustc_data_structures::static_assert_size;
503+
504+
use super::*;
505+
// tidy-alphabetical-start
506+
static_assert_size!(RegionKind<'_>, 20);
507+
static_assert_size!(ty::WithCachedTypeInfo<RegionKind<'_>>, 48);
508+
// tidy-alphabetical-end
509+
}

compiler/rustc_middle/src/ty/sty.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2040,7 +2040,7 @@ mod size_asserts {
20402040

20412041
use super::*;
20422042
// tidy-alphabetical-start
2043-
static_assert_size!(ty::RegionKind<'_>, 20);
2044-
static_assert_size!(ty::TyKind<'_>, 24);
2043+
static_assert_size!(TyKind<'_>, 24);
2044+
static_assert_size!(ty::WithCachedTypeInfo<TyKind<'_>>, 48);
20452045
// tidy-alphabetical-end
20462046
}

0 commit comments

Comments
 (0)