Skip to content

Commit 2c70b4c

Browse files
maximiliano-sThomasLamprecht
authored andcommitted
lang: remove problematic offsetof macro in favor of built-in offset_of
With rust 1.93 the `deref_nullptr` lint changed from a warning to an error [0]. Instead of fixing this macro to not use nullptr anymore, we can just remove it completely, as nowadays one can use the built-in offset_of macro [1], which is available since rust 1.77. Further, checking the source of all our crates [3] did not show any current usage anymore. [0]: rust-lang/rust#148122 [1]: https://doc.rust-lang.org/stable/std/mem/macro.offset_of.html [2]: grep -R 'offsetof!' /usr/share/cargo/registry Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com> Acked-by: Christian Ebner <c.ebner@proxmox.com> Link: https://lore.proxmox.com/20260126141215.401447-1-m.sandoval@proxmox.com [TL: add references and background for why it's fine to remove] Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 parent bcb9c3e commit 2c70b4c

1 file changed

Lines changed: 0 additions & 22 deletions

File tree

proxmox-lang/src/lib.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -66,28 +66,6 @@ macro_rules! static_assert_size {
6666
};
6767
}
6868

69-
/// Evaluates to the offset (in bytes) of a given member within a struct
70-
///
71-
/// ```
72-
/// # use proxmox_lang::offsetof;
73-
///
74-
/// #[repr(C)]
75-
/// struct Stuff {
76-
/// first: u32,
77-
/// second: u32,
78-
/// }
79-
///
80-
/// assert_eq!(offsetof!(Stuff, second), 4);
81-
///
82-
/// ```
83-
#[deprecated = "use std::mem::offset_of! instead"]
84-
#[macro_export]
85-
macro_rules! offsetof {
86-
($ty:ty, $field:ident) => {
87-
unsafe { &(*(std::ptr::null::<$ty>())).$field as *const _ as usize }
88-
};
89-
}
90-
9169
/// Shortcut for generating an `&'static CStr`.
9270
///
9371
/// This takes a *string* (*not* a *byte-string*), appends a terminating zero, and calls

0 commit comments

Comments
 (0)