summaryrefslogtreecommitdiff
path: root/scripts/Makefile.thinlto
diff options
context:
space:
mode:
authorEliot Courtney <ecourtney@nvidia.com>2026-10-13 14:58:06 +0900
committerMiguel Ojeda <ojeda@kernel.org>2026-10-13 12:33:16 +0200
commit1d09c9ee13be740ec0bbf976f14b6f942396cabd (patch)
tree53b80dd2aa8504ad5329d26c932e7bd4eb90b80a /scripts/Makefile.thinlto
parent969a0af79da8ab33f2887376cb69ace62a9285b0 (diff)
downloadlinux-1d09c9ee13be740ec0bbf976f14b6f942396cabd.tar.gz
linux-1d09c9ee13be740ec0bbf976f14b6f942396cabd.zip
rust: num: add cv! macro to create values from constant expressions
Currently, using NonZero/Bounded constants is quite verbose. It's unfortunate because it disincentivizes using it in interface boundaries. Introduce a macro to make it nicer to use. The macro `cv!` (for constant value) takes a const integer expression and widens it to i128 (at build time only) before passing it as a const generic value to a new trait `FromConst`. The value is then converted and appears in the associated constant `FromConst::VALUE`. The trait is implemented by NonZero, Bounded, and Alignment and lets values of each be constructed from constants without a verbose turbofish syntax. For example, `const { NonZero::new(1).unwrap() }` can be written as `cv!(1)`. Add the `cv!` macro to the prelude so it doesn't need to be imported explicitly to use it. Suggested-by: Gary Guo <gary@garyguo.net> Reviewed-by: Gary Guo <gary@garyguo.net> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Acked-by: Danilo Krummrich <dakr@kernel.org> Signed-off-by: Eliot Courtney <ecourtney@nvidia.com> Acked-by: Alexandre Courbot <acourbot@nvidia.com> Link: https://patch.msgid.link/20261013-cv-v5-1-113a538dfaef@nvidia.com [ Added a few intra-doc links. - Miguel ] Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'scripts/Makefile.thinlto')
0 files changed, 0 insertions, 0 deletions