lang: deprecate c_str! and offsetof

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2024-06-20 10:34:00 +02:00
parent 2e9526dcdd
commit 38992a588a

View File

@ -79,12 +79,7 @@ macro_rules! static_assert_size {
/// assert_eq!(offsetof!(Stuff, second), 4); /// assert_eq!(offsetof!(Stuff, second), 4);
/// ///
/// ``` /// ```
// FIXME: With 1.56 we get `const transmute` which may help making this usable `const fn` as we can #[deprecated = "use std::mem::offset_of! instead"]
// avoid dereferencing the raw pointer by transmuting `0usize` into a proper reference instead.
//
// So with 1.56, do this instead:
//
// unsafe { &(std::mem::transmute::<_, &$ty>(0usize).$field) as *const _ as usize }
#[macro_export] #[macro_export]
macro_rules! offsetof { macro_rules! offsetof {
($ty:ty, $field:ident) => { ($ty:ty, $field:ident) => {
@ -103,6 +98,7 @@ macro_rules! offsetof {
/// unsafe { ::std::ffi::CStr::from_bytes_with_nul_unchecked(bytes.as_bytes()) } /// unsafe { ::std::ffi::CStr::from_bytes_with_nul_unchecked(bytes.as_bytes()) }
/// # ; /// # ;
/// ``` /// ```
#[deprecated = "use c\"literals\" instead"]
#[macro_export] #[macro_export]
macro_rules! c_str { macro_rules! c_str {
($data:expr) => {{ ($data:expr) => {{