From 68298a5087307792aec3141db4be8fc9f68b682a Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Tue, 11 Sep 2018 13:30:26 +0200 Subject: [PATCH] Use assertion-like static assertions --- src/librustc/middle/region.rs | 2 +- src/librustc/ty/context.rs | 4 ++-- src/test/ui/consts/const-eval/zst_operand_eval.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 56960675b741..b1d6cce11f43 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -152,7 +152,7 @@ impl_stable_hash_for!(struct ::middle::region::FirstStatementIndex { private }); #[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::() != 4) as usize]; +static ASSERT: () = [()][!(mem::size_of::() == 4) as usize]; #[allow(non_snake_case)] impl Scope { diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index cfc5cd60b178..2aaccb599009 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -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::() <= 24); + static ASSERT_TY_KIND: () = [()][!(std::mem::size_of::() <= 24) as usize]; #[cfg(all(not(stage0), target_pointer_width = "64"))] - assert!(mem::size_of::() <= 32); + static ASSERT_TYS: () = [()][!(std::mem::size_of::() <= 32) as usize]; let mk = |sty| CtxtInterners::intern_ty(interners, interners, sty); let mk_region = |r| { diff --git a/src/test/ui/consts/const-eval/zst_operand_eval.rs b/src/test/ui/consts/const-eval/zst_operand_eval.rs index c6deb88d4f1a..d837da1066da 100644 --- a/src/test/ui/consts/const-eval/zst_operand_eval.rs +++ b/src/test/ui/consts/const-eval/zst_operand_eval.rs @@ -1,5 +1,5 @@ // compile-pass -static ASSERT: () = [()][(std::mem::size_of::() != 4) as usize]; +static ASSERT: () = [()][!(std::mem::size_of::() == 4) as usize]; fn main() {}