Skip to content

Commit 68298a5

Browse files
committed
Use assertion-like static assertions
1 parent 8053f63 commit 68298a5

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/librustc/middle/region.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ impl_stable_hash_for!(struct ::middle::region::FirstStatementIndex { private });
152152
#[allow(dead_code)]
153153
// only works on stage 1 when the rustc_layout_scalar_valid_range attribute actually exists
154154
#[cfg(not(stage0))]
155-
static ASSERT: () = [()][(mem::size_of::<ScopeData>() != 4) as usize];
155+
static ASSERT: () = [()][!(mem::size_of::<ScopeData>() == 4) as usize];
156156

157157
#[allow(non_snake_case)]
158158
impl Scope {

src/librustc/ty/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -830,9 +830,9 @@ impl<'tcx> CommonTypes<'tcx> {
830830
fn new(interners: &CtxtInterners<'tcx>) -> CommonTypes<'tcx> {
831831
// Ensure our type representation does not grow
832832
#[cfg(all(not(stage0), target_pointer_width = "64"))]
833-
assert!(mem::size_of::<ty::TyKind>() <= 24);
833+
static ASSERT_TY_KIND: () = [()][!(std::mem::size_of::<ty::TyKind>() <= 24) as usize];
834834
#[cfg(all(not(stage0), target_pointer_width = "64"))]
835-
assert!(mem::size_of::<ty::TyS>() <= 32);
835+
static ASSERT_TYS: () = [()][!(std::mem::size_of::<ty::TyS>() <= 32) as usize];
836836

837837
let mk = |sty| CtxtInterners::intern_ty(interners, interners, sty);
838838
let mk_region = |r| {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// compile-pass
22

3-
static ASSERT: () = [()][(std::mem::size_of::<u32>() != 4) as usize];
3+
static ASSERT: () = [()][!(std::mem::size_of::<u32>() == 4) as usize];
44

55
fn main() {}

0 commit comments

Comments
 (0)