about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJohn Kåre Alsaker <john.kare.alsaker@gmail.com>2018-05-27 17:13:15 +0200
committerJohn Kåre Alsaker <john.kare.alsaker@gmail.com>2018-05-27 17:28:35 +0200
commit0b6586b989053b98f098928f79e95f3e30b3899c (patch)
tree3e87ff7d03496b7055b9f42d6e18cb0bb88979f8
parent6c2d875261e10105dcfcbd9be84d05a730edd235 (diff)
Add assertions for TyS and TypeVariants sizes
-rw-r--r--src/librustc/ty/context.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs
index 3580926d8ad..2b2da6f842b 100644
--- a/src/librustc/ty/context.rs
+++ b/src/librustc/ty/context.rs
@@ -794,6 +794,12 @@ impl<'a, 'gcx> HashStable<StableHashingContext<'a>> for TypeckTables<'gcx> {
 
 impl<'tcx> CommonTypes<'tcx> {
     fn new(interners: &CtxtInterners<'tcx>) -> CommonTypes<'tcx> {
+        // Ensure our type representation does not grow
+        #[cfg(target_pointer_width = "64")]
+        assert!(mem::size_of::<ty::TypeVariants>() <= 24);
+        #[cfg(target_pointer_width = "64")]
+        assert!(mem::size_of::<ty::TyS>() <= 32);
+
         let mk = |sty| CtxtInterners::intern_ty(interners, interners, sty);
         let mk_region = |r| {
             if let Some(r) = interners.region.borrow().get(&r) {