1 // SPDX-License-Identifier: GPL-2.0
5 /// Static assert (i.e. compile-time assert).
7 /// Similar to C11 [`_Static_assert`] and C++11 [`static_assert`].
9 /// The feature may be added to Rust in the future: see [RFC 2790].
11 /// [`_Static_assert`]: https://en.cppreference.com/w/c/language/_Static_assert
12 /// [`static_assert`]: https://en.cppreference.com/w/cpp/language/static_assert
13 /// [RFC 2790]: https://github.com/rust-lang/rfcs/issues/2790
18 /// static_assert!(42 > 24);
19 /// static_assert!(core::mem::size_of::<u8>() == 1);
21 /// const X: &[u8] = b"bar";
22 /// static_assert!(X[1] == b'a');
24 /// const fn f(x: i32) -> i32 {
27 /// static_assert!(f(40) == 42);
30 macro_rules! static_assert {
31 ($condition:expr) => {
32 const _: () = core::assert!($condition);