diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:59:35 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:59:35 +0000 |
commit | d1b2d29528b7794b41e66fc2136e395a02f8529b (patch) | |
tree | a4a17504b260206dec3cf55b2dca82929a348ac2 /vendor/rustix/src/static_assertions.rs | |
parent | Releasing progress-linux version 1.72.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.tar.xz rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.zip |
Merging upstream version 1.73.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/rustix/src/static_assertions.rs')
-rw-r--r-- | vendor/rustix/src/static_assertions.rs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/vendor/rustix/src/static_assertions.rs b/vendor/rustix/src/static_assertions.rs new file mode 100644 index 000000000..81824cb1c --- /dev/null +++ b/vendor/rustix/src/static_assertions.rs @@ -0,0 +1,37 @@ +//! Workarounds for Rust 1.63 where some things in the `static_assertions` +//! crate do things that don't work in const contexts. We want to call them +//! in const contexts in Rust versions where that's supported so that +//! problems are caught at compile time, and fall back to dynamic asserts +//! in Rust 1.63. + +#![allow(unused_macros)] + +macro_rules! assert_eq_size { + ($x:ty, $y:ty) => { + assert_eq!(core::mem::size_of::<$x>(), core::mem::size_of::<$y>()); + }; +} + +macro_rules! assert_eq_align { + ($x:ty, $y:ty) => { + assert_eq!(core::mem::align_of::<$x>(), core::mem::align_of::<$y>()); + }; +} + +macro_rules! const_assert_eq { + ($x:expr, $y:expr) => { + assert_eq!($x, $y); + }; +} + +macro_rules! const_assert_ne { + ($x:expr, $y:expr) => { + assert_ne!($x, $y); + }; +} + +macro_rules! const_assert { + ($x:expr) => { + assert!($x); + }; +} |