Skip to content

Commit

Permalink
Rollup merge of rust-lang#55945 - oli-obk:static_assert_arg_type, r=m…
Browse files Browse the repository at this point in the history
…ichaelwoerister

Ensure that the argument to `static_assert` is a `bool`

cc @eddyb
  • Loading branch information
kennytm committed Nov 23, 2018
2 parents ef2cbec + 65e6fdb commit 12f6a42
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/librustc_data_structures/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
/// A simple static assertion macro. The first argument should be a unique
/// ALL_CAPS identifier that describes the condition.
#[macro_export]
#[allow_internal_unstable]
macro_rules! static_assert {
($name:ident: $test:expr) => {
// Use the bool to access an array such that if the bool is false, the access
// is out-of-bounds.
#[allow(dead_code)]
static $name: () = [()][!$test as usize];
static $name: () = [()][!($test: bool) as usize];
}
}

0 comments on commit 12f6a42

Please sign in to comment.