]> git.lizzy.rs Git - rust.git/commitdiff
Use assertion-like static assertions
authorOliver Schneider <github35764891676564198441@oli-obk.de>
Tue, 11 Sep 2018 11:30:26 +0000 (13:30 +0200)
committerOliver Schneider <github35764891676564198441@oli-obk.de>
Tue, 11 Sep 2018 11:30:26 +0000 (13:30 +0200)
src/librustc/middle/region.rs
src/librustc/ty/context.rs
src/test/ui/consts/const-eval/zst_operand_eval.rs

index 56960675b74153f3273dfbf47512b8e2140f6986..b1d6cce11f438f3aeabcbe8a16bda26146965735 100644 (file)
@@ -152,7 +152,7 @@ pub struct FirstStatementIndex { .. }
 #[allow(dead_code)]
 // only works on stage 1 when the rustc_layout_scalar_valid_range attribute actually exists
 #[cfg(not(stage0))]
-static ASSERT: () = [()][(mem::size_of::<ScopeData>() != 4) as usize];
+static ASSERT: () = [()][!(mem::size_of::<ScopeData>() == 4) as usize];
 
 #[allow(non_snake_case)]
 impl Scope {
index cfc5cd60b1785df9fe55da5f94f0acd93fdb4677..2aaccb599009d601b8306ba2c0adf9712b28cbe0 100644 (file)
@@ -830,9 +830,9 @@ impl<'tcx> CommonTypes<'tcx> {
     fn new(interners: &CtxtInterners<'tcx>) -> CommonTypes<'tcx> {
         // Ensure our type representation does not grow
         #[cfg(all(not(stage0), target_pointer_width = "64"))]
-        assert!(mem::size_of::<ty::TyKind>() <= 24);
+        static ASSERT_TY_KIND: () = [()][!(std::mem::size_of::<ty::TyKind>() <= 24) as usize];
         #[cfg(all(not(stage0), target_pointer_width = "64"))]
-        assert!(mem::size_of::<ty::TyS>() <= 32);
+        static ASSERT_TYS: () = [()][!(std::mem::size_of::<ty::TyS>() <= 32) as usize];
 
         let mk = |sty| CtxtInterners::intern_ty(interners, interners, sty);
         let mk_region = |r| {
index c6deb88d4f1a158fc6c5b61b51e1717d08ec239c..d837da1066daa79d37c98a88dae7cefa80d536ae 100644 (file)
@@ -1,5 +1,5 @@
 // compile-pass
 
-static ASSERT: () = [()][(std::mem::size_of::<u32>() != 4) as usize];
+static ASSERT: () = [()][!(std::mem::size_of::<u32>() == 4) as usize];
 
 fn main() {}