From 38992a588ac06fc19d88ff17b24d059dbaef6244 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Thu, 20 Jun 2024 10:34:00 +0200 Subject: [PATCH] lang: deprecate c_str! and offsetof Signed-off-by: Wolfgang Bumiller --- proxmox-lang/src/lib.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/proxmox-lang/src/lib.rs b/proxmox-lang/src/lib.rs index 230302e0..0f8195fe 100644 --- a/proxmox-lang/src/lib.rs +++ b/proxmox-lang/src/lib.rs @@ -79,12 +79,7 @@ macro_rules! static_assert_size { /// 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 -// 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 } +#[deprecated = "use std::mem::offset_of! instead"] #[macro_export] macro_rules! offsetof { ($ty:ty, $field:ident) => { @@ -103,6 +98,7 @@ macro_rules! offsetof { /// unsafe { ::std::ffi::CStr::from_bytes_with_nul_unchecked(bytes.as_bytes()) } /// # ; /// ``` +#[deprecated = "use c\"literals\" instead"] #[macro_export] macro_rules! c_str { ($data:expr) => {{