Debian Codegraph @

.cargo/vendor/rustix/src/static_assertions.rs

raw
1 //! Workarounds for Rust 1.63 where some things in the `static_assertions`
2 //! crate do things that don't work in const contexts. We want to call them in
3 //! const contexts in Rust versions where that's supported so that problems are
4 //! caught at compile time, and fall back to dynamic asserts in Rust 1.63.
5
6 #![allow(unused_macros)]
7
8 macro_rules! assert_eq_size {
9 ($x:ty, $y:ty) => {
10 assert_eq!(core::mem::size_of::<$x>(), core::mem::size_of::<$y>());
11 };
12 }
13
14 macro_rules! assert_eq_align {
15 ($x:ty, $y:ty) => {
16 assert_eq!(core::mem::align_of::<$x>(), core::mem::align_of::<$y>());
17 };
18 }
19
20 macro_rules! const_assert_eq {
21 ($x:expr, $y:expr) => {
22 assert_eq!($x, $y);
23 };
24 }
25
26 macro_rules! const_assert_ne {
27 ($x:expr, $y:expr) => {
28 assert_ne!($x, $y);
29 };
30 }
31
32 macro_rules! const_assert {
33 ($x:expr) => {
34 assert!($x);
35 };
36 }