diff options
| author | Oliver Schneider <github35764891676564198441@oli-obk.de> | 2018-09-11 13:30:26 +0200 |
|---|---|---|
| committer | Oliver Schneider <github35764891676564198441@oli-obk.de> | 2018-09-11 13:30:26 +0200 |
| commit | 68298a5087307792aec3141db4be8fc9f68b682a (patch) | |
| tree | 7a6e5a76cb3eb6a8cdcc5e5f417a3eb764dc9d04 | |
| parent | 8053f6319a6c18a23a406e12dede7ff158d3d561 (diff) | |
| download | rust-68298a5087307792aec3141db4be8fc9f68b682a.tar.gz rust-68298a5087307792aec3141db4be8fc9f68b682a.zip | |
Use assertion-like static assertions
| -rw-r--r-- | src/librustc/middle/region.rs | 2 | ||||
| -rw-r--r-- | src/librustc/ty/context.rs | 4 | ||||
| -rw-r--r-- | 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 56960675b74..b1d6cce11f4 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::<ScopeData>() != 4) as usize]; +static ASSERT: () = [()][!(mem::size_of::<ScopeData>() == 4) as usize]; #[allow(non_snake_case)] impl Scope { diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index cfc5cd60b17..2aaccb59900 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::<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| { 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 c6deb88d4f1..d837da1066d 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::<u32>() != 4) as usize]; +static ASSERT: () = [()][!(std::mem::size_of::<u32>() == 4) as usize]; fn main() {} |
