summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorGary Guo <gary@garyguo.net>2026-03-19 15:16:46 +0300
committerMiguel Ojeda <ojeda@kernel.org>2026-03-30 03:03:49 +0300
commit560a7a9b9267fbe31a68270ca0ad22b6a4db44a5 (patch)
treefc1b22fd60a0e9a64a8e01ea42015a61df6dba64 /scripts
parentabfe5ee9971249b91020b5053afcaad43837336a (diff)
downloadlinux-560a7a9b9267fbe31a68270ca0ad22b6a4db44a5.tar.xz
rust: add `const_assert!` macro
The macro is a more powerful version of `static_assert!` for use inside function contexts. This is powered by inline consts, so enable the feature for old compiler versions that does not have it stably. While it is possible already to write `const { assert!(...) }`, this provides a short hand that is more uniform with other assertions. It also formats nicer with rustfmt where it will not be formatted into multiple lines. Two users that would route via the Rust tree are converted. Reviewed-by: Yury Norov <ynorov@nvidia.com> Signed-off-by: Gary Guo <gary@garyguo.net> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Danilo Krummrich <dakr@kernel.org> Link: https://patch.msgid.link/20260319121653.2975748-3-gary@kernel.org [ Rebased. Fixed period typo. - Miguel ] Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Makefile.build3
1 files changed, 2 insertions, 1 deletions
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 32e209bc7985..0328afd5ee96 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -310,6 +310,7 @@ $(obj)/%.lst: $(obj)/%.c FORCE
# The features in this list are the ones allowed for non-`rust/` code.
#
+# - Stable since Rust 1.79.0: `feature(inline_const)`.
# - Stable since Rust 1.81.0: `feature(lint_reasons)`.
# - Stable since Rust 1.82.0: `feature(asm_const)`,
# `feature(offset_of_nested)`, `feature(raw_ref_op)`.
@@ -319,7 +320,7 @@ $(obj)/%.lst: $(obj)/%.c FORCE
#
# Please see https://github.com/Rust-for-Linux/linux/issues/2 for details on
# the unstable features in use.
-rust_allowed_features := asm_const,asm_goto,arbitrary_self_types,lint_reasons,offset_of_nested,raw_ref_op,used_with_arg
+rust_allowed_features := asm_const,asm_goto,arbitrary_self_types,inline_const,lint_reasons,offset_of_nested,raw_ref_op,used_with_arg
# `--out-dir` is required to avoid temporaries being created by `rustc` in the
# current working directory, which may be not accessible in the out-of-tree