]> git.lizzy.rs Git - rust.git/blob - src/librustc_data_structures/macros.rs
Merge remote-tracking branch 'upstream/master'
[rust.git] / src / librustc_data_structures / macros.rs
1 /// A simple static assertion macro. The first argument should be a unique
2 /// ALL_CAPS identifier that describes the condition.
3 #[macro_export]
4 #[cfg_attr(stage0, allow_internal_unstable)]
5 #[cfg_attr(not(stage0), allow_internal_unstable(type_ascription))]
6 macro_rules! static_assert {
7     ($name:ident: $test:expr) => {
8         // Use the bool to access an array such that if the bool is false, the access
9         // is out-of-bounds.
10         #[allow(dead_code)]
11         static $name: () = [()][!($test: bool) as usize];
12     }
13 }