1
Fork 0

Use assertion-like static assertions

This commit is contained in:
Oliver Schneider 2018-09-11 13:30:26 +02:00
parent 8053f6319a
commit 68298a5087
3 changed files with 4 additions and 4 deletions

View file

@ -152,7 +152,7 @@ impl_stable_hash_for!(struct ::middle::region::FirstStatementIndex { private });
#[allow(dead_code)] #[allow(dead_code)]
// only works on stage 1 when the rustc_layout_scalar_valid_range attribute actually exists // only works on stage 1 when the rustc_layout_scalar_valid_range attribute actually exists
#[cfg(not(stage0))] #[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)] #[allow(non_snake_case)]
impl Scope { impl Scope {

View file

@ -830,9 +830,9 @@ impl<'tcx> CommonTypes<'tcx> {
fn new(interners: &CtxtInterners<'tcx>) -> CommonTypes<'tcx> { fn new(interners: &CtxtInterners<'tcx>) -> CommonTypes<'tcx> {
// Ensure our type representation does not grow // Ensure our type representation does not grow
#[cfg(all(not(stage0), target_pointer_width = "64"))] #[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"))] #[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 = |sty| CtxtInterners::intern_ty(interners, interners, sty);
let mk_region = |r| { let mk_region = |r| {

View file

@ -1,5 +1,5 @@
// compile-pass // compile-pass
static ASSERT: () = [()][(std::mem::size_of::<u32>() != 4) as usize]; static ASSERT: () = [()][!(std::mem::size_of::<u32>() == 4) as usize];
fn main() {} fn main() {}