diff --git a/Cargo.lock b/Cargo.lock index 25e822d166..42b7c3f558 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3329,6 +3329,7 @@ dependencies = [ "roc_collections", "roc_ident", "roc_region", + "static_assertions", ] [[package]] @@ -3461,6 +3462,7 @@ dependencies = [ "roc_collections", "roc_module", "roc_region", + "static_assertions", "ven_ena", ] diff --git a/cli/cli_utils/src/helpers.rs b/cli/cli_utils/src/helpers.rs index e5beddfecb..11a6a404f3 100644 --- a/cli/cli_utils/src/helpers.rs +++ b/cli/cli_utils/src/helpers.rs @@ -1,5 +1,4 @@ extern crate bumpalo; -extern crate inlinable_string; extern crate roc_collections; extern crate roc_load; extern crate roc_module; diff --git a/cli/tests/cli_run.rs b/cli/tests/cli_run.rs index 0494d35f41..0fb00a9e48 100644 --- a/cli/tests/cli_run.rs +++ b/cli/tests/cli_run.rs @@ -2,7 +2,6 @@ extern crate pretty_assertions; extern crate bumpalo; -extern crate inlinable_string; extern crate roc_collections; extern crate roc_load; extern crate roc_module; diff --git a/compiler/load/tests/test_load.rs b/compiler/load/tests/test_load.rs index d77e74ee38..7fbdae8ba7 100644 --- a/compiler/load/tests/test_load.rs +++ b/compiler/load/tests/test_load.rs @@ -6,7 +6,6 @@ extern crate pretty_assertions; extern crate maplit; extern crate bumpalo; -extern crate inlinable_string; extern crate roc_collections; extern crate roc_load; extern crate roc_module; diff --git a/compiler/module/Cargo.toml b/compiler/module/Cargo.toml index c20acb533e..239468c8c6 100644 --- a/compiler/module/Cargo.toml +++ b/compiler/module/Cargo.toml @@ -11,6 +11,7 @@ roc_ident = { path = "../ident" } roc_collections = { path = "../collections" } bumpalo = { version = "3.6.1", features = ["collections"] } lazy_static = "1.4" +static_assertions = "1.1.0" [dev-dependencies] pretty_assertions = "0.5.1" diff --git a/compiler/module/src/ident.rs b/compiler/module/src/ident.rs index 484ecfe785..0de36bd0bd 100644 --- a/compiler/module/src/ident.rs +++ b/compiler/module/src/ident.rs @@ -59,6 +59,8 @@ pub enum TagName { Closure(Symbol), } +static_assertions::assert_eq_size!([u8; 24], TagName); + impl TagName { pub fn as_ident_str(&self, interns: &Interns, home: ModuleId) -> IdentStr { match self { diff --git a/compiler/solve/tests/solve_expr.rs b/compiler/solve/tests/solve_expr.rs index e303608141..92907af3f7 100644 --- a/compiler/solve/tests/solve_expr.rs +++ b/compiler/solve/tests/solve_expr.rs @@ -4488,18 +4488,4 @@ mod solve_expr { "RBTree {}", ); } - - #[test] - fn sizes() { - let query = ( - std::mem::size_of::(), - std::mem::size_of::(), - std::mem::size_of::(), - std::mem::size_of::(), - std::mem::size_of::(), - ); - - // without RecordFields in FlatType assert_eq!((40, 72, 56, 48, 64), query) - assert_eq!((24, 104, 88, 80, 48), query) - } } diff --git a/compiler/types/Cargo.toml b/compiler/types/Cargo.toml index de242bf348..512437bd66 100644 --- a/compiler/types/Cargo.toml +++ b/compiler/types/Cargo.toml @@ -10,6 +10,7 @@ roc_collections = { path = "../collections" } roc_region = { path = "../region" } roc_module = { path = "../module" } ven_ena = { path = "../../vendor/ena" } +static_assertions = "1.1.0" [dev-dependencies] pretty_assertions = "0.5.1" diff --git a/compiler/types/src/subs.rs b/compiler/types/src/subs.rs index 67f3174ed8..23144a6c98 100644 --- a/compiler/types/src/subs.rs +++ b/compiler/types/src/subs.rs @@ -7,6 +7,13 @@ use std::fmt; use std::iter::{once, Extend, FromIterator, Iterator, Map, Zip}; use ven_ena::unify::{InPlace, Snapshot, UnificationTable, UnifyKey}; +// if your changes cause this number to go down, great! +// please change it to the lower number. +// if it went up, maybe check that the change is really required +static_assertions::assert_eq_size!([u8; 104], Descriptor); +static_assertions::assert_eq_size!([u8; 88], Content); +static_assertions::assert_eq_size!([u8; 80], FlatType); + #[derive(Clone, Copy, Hash, PartialEq, Eq)] pub struct Mark(i32); @@ -494,7 +501,7 @@ fn unnamed_flex_var() -> Content { } #[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub struct Rank(usize); +pub struct Rank(u32); impl Rank { pub const NONE: Rank = Rank(0); @@ -508,7 +515,7 @@ impl Rank { } pub fn into_usize(self) -> usize { - self.0 + self.0 as usize } } @@ -526,13 +533,13 @@ impl fmt::Debug for Rank { impl From for usize { fn from(rank: Rank) -> Self { - rank.0 + rank.0 as usize } } impl From for Rank { fn from(index: usize) -> Self { - Rank(index) + Rank(index as u32) } }