aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Duerr <chrisduerr@users.noreply.github.com>2018-07-05 23:05:33 +0000
committerGitHub <noreply@github.com>2018-07-05 23:05:33 +0000
commit7433f45ff9c6efeb48e223e90dd4aa9ee135b5e8 (patch)
tree8fac2cfad590b8ead771cdd4fbfb818936b6308b /src
parent68b3d8abfdeeb388edb1b5e0528d3fddb66fd9e8 (diff)
downloadalacritty-7433f45ff9c6efeb48e223e90dd4aa9ee135b5e8.tar.gz
alacritty-7433f45ff9c6efeb48e223e90dd4aa9ee135b5e8.zip
Replace debug asserts with static_assertions
To check that transmutes will work correctly without having to rely on error-prone runtime checking, the `static_assertions` crate has been introduced. This allows comparing the size of types at compile time, preventing potentially silent breakage. This fixes #1417.
Diffstat (limited to 'src')
-rw-r--r--src/input.rs2
-rw-r--r--src/lib.rs1
2 files changed, 2 insertions, 1 deletions
diff --git a/src/input.rs b/src/input.rs
index aa00ee3d..701feea1 100644
--- a/src/input.rs
+++ b/src/input.rs
@@ -137,7 +137,7 @@ impl<T> Binding<T> {
/// Optimized to use single check instead of four (one per modifier)
#[inline]
fn mods_match(&self, mods: ModifiersState) -> bool {
- debug_assert!(4 == mem::size_of::<ModifiersState>());
+ assert_eq_size!(ModifiersState, u32);
unsafe {
mem::transmute_copy::<_, u32>(&self.mods) == mem::transmute_copy::<_, u32>(&mods)
}
diff --git a/src/lib.rs b/src/lib.rs
index d6229ee7..d9006fe0 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -21,6 +21,7 @@
#[macro_use] extern crate clap;
#[macro_use] extern crate log;
#[macro_use] extern crate serde_derive;
+#[macro_use] extern crate static_assertions;
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os="dragonfly", target_os="openbsd"))]
extern crate x11_dl;