From 8372b50a6faa2883a6bd15fde121fcb47e6d43e9 Mon Sep 17 00:00:00 2001 From: dybucc <149513579+dybucc@users.noreply.github.com> Date: Thu, 18 Jun 2026 15:53:52 +0200 Subject: [PATCH 1/2] feat: add macro to declare unstable constants This patch adds a new macro that can be used for declaring constants when these are known to possibly change upstream across target OS/ABI versions. --- src/macros.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/macros.rs b/src/macros.rs index 0149b1fd18466..5c5b8c2deac79 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -402,6 +402,21 @@ macro_rules! offset_of { }}; } +/// Defines constants with an accompanying doc comment pointing out their +/// instability, and links to the crate documentation for usage guidelines. +macro_rules! ct { + ($($it:item)+) => { +$( +/// This constant, among others often used in C for the purposes of denoting the +/// latest value or limit in a set of constants, is likely to change upstream. +/// For correct usage, see the [crate-level documentation][docs]. +/// +/// [docs]: index.html#usage-recommendations +$it +)+ + }; +} + #[cfg(test)] mod tests { use core::any::TypeId; From 7c454598c06c4f7619deaa2c51b71be2b91d85ae Mon Sep 17 00:00:00 2001 From: dybucc <149513579+dybucc@users.noreply.github.com> Date: Sat, 30 May 2026 17:49:34 +0200 Subject: [PATCH 2/2] refactor: deprecate constants matching `_NUM` These symbols, alongside those matching the `_MAX`, `_COUNT` and `_LAST`-suffixed constants, have been deprecated in favor of keeping more stable SemVer guarantees. For more on the reasons why some of these constants were deprecated, while others weren't, see the accompanying PR. --- src/unix/linux_like/linux_l4re_shared.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/unix/linux_like/linux_l4re_shared.rs b/src/unix/linux_like/linux_l4re_shared.rs index 041e2525d9bc8..8cf206a6366fe 100644 --- a/src/unix/linux_like/linux_l4re_shared.rs +++ b/src/unix/linux_like/linux_l4re_shared.rs @@ -690,7 +690,10 @@ pub const EI_CLASS: usize = 4; pub const ELFCLASSNONE: u8 = 0; pub const ELFCLASS32: u8 = 1; pub const ELFCLASS64: u8 = 2; -pub const ELFCLASSNUM: usize = 3; + +ct! { + pub const ELFCLASSNUM: usize = 3; +} pub const EI_DATA: usize = 5; pub const ELFDATANONE: u8 = 0; @@ -821,7 +824,10 @@ pub const EM_ALPHA: u16 = 0x9026; // elf.h - Legal values for e_version (version). pub const EV_NONE: u32 = 0; pub const EV_CURRENT: u32 = 1; -pub const EV_NUM: u32 = 2; + +ct! { + pub const EV_NUM: u32 = 2; +} // elf.h - Legal values for p_type (segment type). pub const PT_NULL: u32 = 0;