public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 1/4] rust: move `static_assert` into `build_assert`
       [not found] <20260319121653.2975748-1-gary@kernel.org>
@ 2026-03-19 12:16 ` Gary Guo
  2026-03-19 14:09   ` Alice Ryhl
  2026-03-19 12:16 ` [PATCH v3 2/4] rust: add `const_assert!` macro Gary Guo
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 22+ messages in thread
From: Gary Guo @ 2026-03-19 12:16 UTC (permalink / raw)
  To: Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich
  Cc: Yury Norov, rust-for-linux, linux-kernel

From: Gary Guo <gary@garyguo.net>

Conceptually, `static_assert` is also a build-time assertion that occurs
earlier in the pipeline. Consolidate the implementation so that we can use
this as the canonical place to add more useful build-time assertions.

Reviewed-by: Yury Norov <ynorov@nvidia.com>
Signed-off-by: Gary Guo <gary@garyguo.net>
---
 rust/kernel/build_assert.rs  | 40 +++++++++++++++++++++++++++++++++---
 rust/kernel/lib.rs           |  1 -
 rust/kernel/prelude.rs       |  4 +---
 rust/kernel/static_assert.rs | 39 -----------------------------------
 4 files changed, 38 insertions(+), 46 deletions(-)
 delete mode 100644 rust/kernel/static_assert.rs

diff --git a/rust/kernel/build_assert.rs b/rust/kernel/build_assert.rs
index f8124dbc663f..d464494d430a 100644
--- a/rust/kernel/build_assert.rs
+++ b/rust/kernel/build_assert.rs
@@ -1,10 +1,46 @@
 // SPDX-License-Identifier: GPL-2.0
 
-//! Build-time assert.
+//! Various assertions that happen during build-time.
 
 #[doc(hidden)]
 pub use build_error::build_error;
 
+/// Static assert (i.e. compile-time assert).
+///
+/// Similar to C11 [`_Static_assert`] and C++11 [`static_assert`].
+///
+/// An optional panic message can be supplied after the expression.
+/// Currently only a string literal without formatting is supported
+/// due to constness limitations of the [`assert!`] macro.
+///
+/// The feature may be added to Rust in the future: see [RFC 2790].
+///
+/// [`_Static_assert`]: https://en.cppreference.com/w/c/language/_Static_assert
+/// [`static_assert`]: https://en.cppreference.com/w/cpp/language/static_assert
+/// [RFC 2790]: https://github.com/rust-lang/rfcs/issues/2790
+///
+/// # Examples
+///
+/// ```
+/// static_assert!(42 > 24);
+/// static_assert!(core::mem::size_of::<u8>() == 1);
+///
+/// const X: &[u8] = b"bar";
+/// static_assert!(X[1] == b'a');
+///
+/// const fn f(x: i32) -> i32 {
+///     x + 2
+/// }
+/// static_assert!(f(40) == 42);
+/// static_assert!(f(40) == 42, "f(x) must add 2 to the given input.");
+/// ```
+#[macro_export]
+macro_rules! static_assert {
+    ($condition:expr $(,$arg:literal)?) => {
+        const _: () = ::core::assert!($condition $(,$arg)?);
+    };
+}
+
 /// Fails the build if the code path calling `build_error!` can possibly be executed.
 ///
 /// If the macro is executed in const context, `build_error!` will panic.
@@ -74,8 +110,6 @@ macro_rules! build_error {
 ///     assert!(n > 1); // Run-time check
 /// }
 /// ```
-///
-/// [`static_assert!`]: crate::static_assert!
 #[macro_export]
 macro_rules! build_assert {
     ($cond:expr $(,)?) => {{
diff --git a/rust/kernel/lib.rs b/rust/kernel/lib.rs
index 34b924819288..f427cd3c8cce 100644
--- a/rust/kernel/lib.rs
+++ b/rust/kernel/lib.rs
@@ -151,7 +151,6 @@
 pub mod slice;
 #[cfg(CONFIG_SOC_BUS)]
 pub mod soc;
-mod static_assert;
 #[doc(hidden)]
 pub mod std_vendor;
 pub mod str;
diff --git a/rust/kernel/prelude.rs b/rust/kernel/prelude.rs
index 2877e3f7b6d3..c7e91b80d301 100644
--- a/rust/kernel/prelude.rs
+++ b/rust/kernel/prelude.rs
@@ -29,7 +29,7 @@
 
 pub use pin_init::{init, pin_data, pin_init, pinned_drop, InPlaceWrite, Init, PinInit, Zeroable};
 
-pub use super::{build_assert, build_error};
+pub use super::{build_assert, build_error, static_assert};
 
 // `super::std_vendor` is hidden, which makes the macro inline for some reason.
 #[doc(no_inline)]
@@ -39,8 +39,6 @@
 
 pub use super::{try_init, try_pin_init};
 
-pub use super::static_assert;
-
 pub use super::error::{code::*, Error, Result};
 
 pub use super::{str::CStrExt as _, ThisModule};
diff --git a/rust/kernel/static_assert.rs b/rust/kernel/static_assert.rs
deleted file mode 100644
index a57ba14315a0..000000000000
--- a/rust/kernel/static_assert.rs
+++ /dev/null
@@ -1,39 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-
-//! Static assert.
-
-/// Static assert (i.e. compile-time assert).
-///
-/// Similar to C11 [`_Static_assert`] and C++11 [`static_assert`].
-///
-/// An optional panic message can be supplied after the expression.
-/// Currently only a string literal without formatting is supported
-/// due to constness limitations of the [`assert!`] macro.
-///
-/// The feature may be added to Rust in the future: see [RFC 2790].
-///
-/// [`_Static_assert`]: https://en.cppreference.com/w/c/language/_Static_assert
-/// [`static_assert`]: https://en.cppreference.com/w/cpp/language/static_assert
-/// [RFC 2790]: https://github.com/rust-lang/rfcs/issues/2790
-///
-/// # Examples
-///
-/// ```
-/// static_assert!(42 > 24);
-/// static_assert!(core::mem::size_of::<u8>() == 1);
-///
-/// const X: &[u8] = b"bar";
-/// static_assert!(X[1] == b'a');
-///
-/// const fn f(x: i32) -> i32 {
-///     x + 2
-/// }
-/// static_assert!(f(40) == 42);
-/// static_assert!(f(40) == 42, "f(x) must add 2 to the given input.");
-/// ```
-#[macro_export]
-macro_rules! static_assert {
-    ($condition:expr $(,$arg:literal)?) => {
-        const _: () = ::core::assert!($condition $(,$arg)?);
-    };
-}
-- 
2.51.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 2/4] rust: add `const_assert!` macro
       [not found] <20260319121653.2975748-1-gary@kernel.org>
  2026-03-19 12:16 ` [PATCH v3 1/4] rust: move `static_assert` into `build_assert` Gary Guo
@ 2026-03-19 12:16 ` Gary Guo
  2026-03-19 14:12   ` Alice Ryhl
  2026-03-21 13:05   ` Alexandre Courbot
  2026-03-19 12:16 ` [PATCH v3 3/4] rust: rework `build_assert!` documentation Gary Guo
  2026-03-19 12:16 ` [PATCH v3 4/4] rust: make `build_assert` module the home of related macros Gary Guo
  3 siblings, 2 replies; 22+ messages in thread
From: Gary Guo @ 2026-03-19 12:16 UTC (permalink / raw)
  To: Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich, Alexandre Courbot, Yury Norov,
	Nathan Chancellor, Nicolas Schier
  Cc: Yury Norov, rust-for-linux, linux-kernel, linux-kbuild

From: Gary Guo <gary@garyguo.net>

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>
---
 rust/kernel/build_assert.rs | 24 ++++++++++++++++++++++++
 rust/kernel/num/bounded.rs  | 24 +++++++++---------------
 rust/kernel/prelude.rs      |  7 ++++++-
 rust/kernel/ptr.rs          | 12 ++++++------
 scripts/Makefile.build      |  5 +++--
 5 files changed, 48 insertions(+), 24 deletions(-)

diff --git a/rust/kernel/build_assert.rs b/rust/kernel/build_assert.rs
index d464494d430a..50b0fc0a80fc 100644
--- a/rust/kernel/build_assert.rs
+++ b/rust/kernel/build_assert.rs
@@ -41,6 +41,30 @@ macro_rules! static_assert {
     };
 }
 
+/// Assertion during constant evaluation.
+///
+/// This is a more powerful version of [`static_assert!`] that can refer to generics inside
+/// functions or implementation blocks. However, it also has a limitation where it can only appear
+/// in places where statements can appear; for example, you cannot use it as an item in the module.
+///
+/// # Examples
+///
+/// ```
+/// fn foo<const N: usize>() {
+///     const_assert!(N > 1);
+/// }
+///
+/// fn bar<T>() {
+///     const_assert!(size_of::<T>() > 0, "T cannot be ZST");
+/// }
+/// ```
+#[macro_export]
+macro_rules! const_assert {
+    ($condition:expr $(,$arg:literal)?) => {
+        const { ::core::assert!($condition $(,$arg)?) };
+    };
+}
+
 /// Fails the build if the code path calling `build_error!` can possibly be executed.
 ///
 /// If the macro is executed in const context, `build_error!` will panic.
diff --git a/rust/kernel/num/bounded.rs b/rust/kernel/num/bounded.rs
index bbab6bbcb315..f9f90d6ec482 100644
--- a/rust/kernel/num/bounded.rs
+++ b/rust/kernel/num/bounded.rs
@@ -255,9 +255,7 @@ impl<const N: u32> Bounded<$type, N> {
             /// ```
             pub const fn new<const VALUE: $type>() -> Self {
                 // Statically assert that `VALUE` fits within the set number of bits.
-                const {
-                    assert!(fits_within!(VALUE, $type, N));
-                }
+                const_assert!(fits_within!(VALUE, $type, N));
 
                 // SAFETY: `fits_within` confirmed that `VALUE` can be represented within
                 // `N` bits.
@@ -287,12 +285,10 @@ impl<T, const N: u32> Bounded<T, N>
     /// The caller must ensure that `value` can be represented within `N` bits.
     const unsafe fn __new(value: T) -> Self {
         // Enforce the type invariants.
-        const {
-            // `N` cannot be zero.
-            assert!(N != 0);
-            // The backing type is at least as large as `N` bits.
-            assert!(N <= T::BITS);
-        }
+        // `N` cannot be zero.
+        const_assert!(N != 0);
+        // The backing type is at least as large as `N` bits.
+        const_assert!(N <= T::BITS);
 
         // INVARIANT: The caller ensures `value` fits within `N` bits.
         Self(value)
@@ -409,12 +405,10 @@ pub const fn get(self) -> T {
     /// assert_eq!(larger_v, v);
     /// ```
     pub const fn extend<const M: u32>(self) -> Bounded<T, M> {
-        const {
-            assert!(
-                M >= N,
-                "Requested number of bits is less than the current representation."
-            );
-        }
+        const_assert!(
+            M >= N,
+            "Requested number of bits is less than the current representation."
+        );
 
         // SAFETY: The value did fit within `N` bits, so it will all the more fit within
         // the larger `M` bits.
diff --git a/rust/kernel/prelude.rs b/rust/kernel/prelude.rs
index c7e91b80d301..6a54597fa0a2 100644
--- a/rust/kernel/prelude.rs
+++ b/rust/kernel/prelude.rs
@@ -29,7 +29,12 @@
 
 pub use pin_init::{init, pin_data, pin_init, pinned_drop, InPlaceWrite, Init, PinInit, Zeroable};
 
-pub use super::{build_assert, build_error, static_assert};
+pub use super::{
+    build_assert,
+    build_error,
+    const_assert,
+    static_assert, //
+};
 
 // `super::std_vendor` is hidden, which makes the macro inline for some reason.
 #[doc(no_inline)]
diff --git a/rust/kernel/ptr.rs b/rust/kernel/ptr.rs
index bdc2d79ff669..d05e5888e80c 100644
--- a/rust/kernel/ptr.rs
+++ b/rust/kernel/ptr.rs
@@ -11,6 +11,8 @@
 };
 use core::num::NonZero;
 
+use crate::const_assert;
+
 /// Type representing an alignment, which is always a power of two.
 ///
 /// It is used to validate that a given value is a valid alignment, and to perform masking and
@@ -44,12 +46,10 @@ impl Alignment {
     /// ```
     #[inline(always)]
     pub const fn new<const ALIGN: usize>() -> Self {
-        const {
-            assert!(
-                ALIGN.is_power_of_two(),
-                "Provided alignment is not a power of two."
-            );
-        }
+        const_assert!(
+            ALIGN.is_power_of_two(),
+            "Provided alignment is not a power of two."
+        );
 
         // INVARIANT: `align` is a power of two.
         // SAFETY: `align` is a power of two, and thus non-zero.
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 010d08472fb2..195a8b7016f3 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -310,7 +310,8 @@ $(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(slice_ptr_len)`.
+#   - Stable since Rust 1.79.0: `feature(inline_const)`,
+#     `feature(slice_ptr_len)`,
 #   - 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)`.
@@ -322,7 +323,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,generic_arg_infer,lint_reasons,offset_of_nested,raw_ref_op,slice_ptr_len,strict_provenance,used_with_arg
+rust_allowed_features := asm_const,asm_goto,arbitrary_self_types,generic_arg_infer,inline_const,lint_reasons,offset_of_nested,raw_ref_op,slice_ptr_len,strict_provenance,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
-- 
2.51.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 3/4] rust: rework `build_assert!` documentation
       [not found] <20260319121653.2975748-1-gary@kernel.org>
  2026-03-19 12:16 ` [PATCH v3 1/4] rust: move `static_assert` into `build_assert` Gary Guo
  2026-03-19 12:16 ` [PATCH v3 2/4] rust: add `const_assert!` macro Gary Guo
@ 2026-03-19 12:16 ` Gary Guo
  2026-03-19 14:17   ` Alice Ryhl
  2026-03-21 13:05   ` Alexandre Courbot
  2026-03-19 12:16 ` [PATCH v3 4/4] rust: make `build_assert` module the home of related macros Gary Guo
  3 siblings, 2 replies; 22+ messages in thread
From: Gary Guo @ 2026-03-19 12:16 UTC (permalink / raw)
  To: Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich
  Cc: Yury Norov, rust-for-linux, linux-kernel

From: Gary Guo <gary@garyguo.net>

Add a detailed comparison and recommendation of the three types of
build-time assertion macro as module documentation (and un-hide the module
to render them).

The documentation on the macro themselves are simplified to only cover the
scenarios where they should be used; links to the module documentation is
added instead.

Reviewed-by: Yury Norov <ynorov@nvidia.com>
Signed-off-by: Gary Guo <gary@garyguo.net>
---
 rust/kernel/build_assert.rs | 119 ++++++++++++++++++++++++++++--------
 rust/kernel/lib.rs          |   1 -
 2 files changed, 92 insertions(+), 28 deletions(-)

diff --git a/rust/kernel/build_assert.rs b/rust/kernel/build_assert.rs
index 50b0fc0a80fc..726d0b76ca2b 100644
--- a/rust/kernel/build_assert.rs
+++ b/rust/kernel/build_assert.rs
@@ -1,6 +1,72 @@
 // SPDX-License-Identifier: GPL-2.0
 
 //! Various assertions that happen during build-time.
+//!
+//! There are three types of build-time assertions that you can use:
+//! - [`static_assert!`]
+//! - [`const_assert!`]
+//! - [`build_assert!`]
+//!
+//! The ones towards the bottom of the list are more expressive, while the ones towards the top of
+//! the list are more robust and trigger earlier in the compilation pipeline. Therefore, you should
+//! prefer the ones towards the top of the list wherever possible.
+//!
+//! # Choosing the correct assertion
+//!
+//! If you're asserting outside any bodies (e.g. initializers or function bodies), you should use
+//! [`static_assert!`] as it is the only assertion that can be used in that context.
+//!
+//! Inside bodies, if your assertion condition does not depend on any variable or generics, you
+//! should use [`static_assert!`]. If the condition depends on generics, but not variables
+//! (including function arguments), you should use [`const_assert!`]. Otherwise, use
+//! [`build_assert!`]. The same is true regardless if the function is `const fn`.
+//!
+//! ```
+//! // Outside any bodies
+//! static_assert!(core::mem::size_of::<u8>() == 1);
+//! // `const_assert!` and `build_assert!` cannot be used here, they will fail to compile.
+//!
+//! #[inline(always)]
+//! fn foo<const N: usize>(v: usize) {
+//!     static_assert!(core::mem::size_of::<u8>() == 1); // Preferred
+//!     const_assert!(core::mem::size_of::<u8>() == 1); // Discouraged
+//!     build_assert!(core::mem::size_of::<u8>() == 1); // Discouraged
+//!
+//!     // `static_assert!(N > 1);` is not allowed
+//!     const_assert!(N > 1); // Preferred
+//!     build_assert!(N > 1); // Discouraged
+//!
+//!     // `static_assert!(v > 1);` is not allowed
+//!     // `const_assert!(v > 1);` is not allowed
+//!     build_assert!(v > 1); // Works
+//! }
+//! ```
+//!
+//! # Detailed behavior
+//!
+//! `static_assert!()` is equivalent to `static_assert` in C. It requires `expr` to be a constant
+//! expression. This expression cannot refer to any generics. A `static_assert!(expr)` in a program
+//! is always evaluated, regardless if the function it appears in is used or not. This is also the
+//! only usable assertion outside a body.
+//!
+//! `const_assert!()` has no direct C equivalence. It is a more powerful version of
+//! `static_assert!()`, where it may refer to generics in a function. Note that due to the ability
+//! to refer to generics, the assertion is tied to a specific instance of a function. So if it is
+//! used in a generic function that is not instantiated, the assertion will not be checked. For this
+//! reason, `static_assert!()` is preferred wherever possible.
+//!
+//! `build_assert!()` is equivalent to `BUILD_BUG_ON`. It is even more powerful than
+//! `const_assert!()` because it can be used to check tautologies that depend on runtime value (this
+//! is the same as `BUILD_BUG_ON`). However, the assertion failure mechanism can possibly be
+//! undefined symbols and linker errors, it is not developer friendly to debug, so it is recommended
+//! to avoid it and prefer other two assertions where possible.
+
+pub use crate::{
+    build_assert,
+    build_error,
+    const_assert,
+    static_assert, //
+};
 
 #[doc(hidden)]
 pub use build_error::build_error;
@@ -15,6 +81,10 @@
 ///
 /// The feature may be added to Rust in the future: see [RFC 2790].
 ///
+/// You cannot refer to generics or variables with [`static_assert!`]. If you need to refer to
+/// generics, use [`const_assert!`]; if you need to refer to variables, use [`build_assert!`]. See
+/// the [module documentation](self).
+///
 /// [`_Static_assert`]: https://en.cppreference.com/w/c/language/_Static_assert
 /// [`static_assert`]: https://en.cppreference.com/w/cpp/language/static_assert
 /// [RFC 2790]: https://github.com/rust-lang/rfcs/issues/2790
@@ -47,6 +117,10 @@ macro_rules! static_assert {
 /// functions or implementation blocks. However, it also has a limitation where it can only appear
 /// in places where statements can appear; for example, you cannot use it as an item in the module.
 ///
+/// [`static_assert!`] should be preferred if no generics are referred to in the condition. You
+/// cannot refer to variables with [`const_assert!`] (even inside `const fn`); if you need the
+/// capability, use [`build_assert!`]. See the [module documentation](self).
+///
 /// # Examples
 ///
 /// ```
@@ -98,41 +172,32 @@ macro_rules! build_error {
 /// will panic. If the compiler or optimizer cannot guarantee the condition will
 /// be evaluated to `true`, a build error will be triggered.
 ///
-/// [`static_assert!`] should be preferred to `build_assert!` whenever possible.
+/// When a condition depends on a function argument, the function must be annotated with
+/// `#[inline(always)]`. Without this attribute, the compiler may choose to not inline the
+/// function, preventing it from optimizing out the error path.
+///
+/// If the assertion condition does not depend on any variables or generics, you should use
+/// [`static_assert!`]. If the assertion condition does not depend on variables, but does depend on
+/// generics, you should use [`const_assert!`]. See the [module documentation](self).
 ///
 /// # Examples
 ///
-/// These examples show that different types of [`assert!`] will trigger errors
-/// at different stage of compilation. It is preferred to err as early as
-/// possible, so [`static_assert!`] should be used whenever possible.
-/// ```ignore
-/// fn foo() {
-///     static_assert!(1 > 1); // Compile-time error
-///     build_assert!(1 > 1); // Build-time error
-///     assert!(1 > 1); // Run-time error
-/// }
 /// ```
+/// #[inline(always)] // Important
+/// fn bar(n: usize) {
+///     build_assert!(n > 1);
+/// }
 ///
-/// When the condition refers to generic parameters or parameters of an inline function,
-/// [`static_assert!`] cannot be used. Use `build_assert!` in this scenario.
-/// ```
-/// fn foo<const N: usize>() {
-///     // `static_assert!(N > 1);` is not allowed
-///     build_assert!(N > 1); // Build-time check
-///     assert!(N > 1); // Run-time check
+/// fn foo() {
+///     bar(2);
 /// }
-/// ```
 ///
-/// When a condition depends on a function argument, the function must be annotated with
-/// `#[inline(always)]`. Without this attribute, the compiler may choose to not inline the
-/// function, preventing it from optimizing out the error path.
-/// ```
-/// #[inline(always)]
-/// fn bar(n: usize) {
-///     // `static_assert!(n > 1);` is not allowed
-///     build_assert!(n > 1); // Build-time check
-///     assert!(n > 1); // Run-time check
+/// #[inline(always)] // Important
+/// const fn const_bar(n: usize) {
+///     build_assert!(n > 1);
 /// }
+///
+/// const _: () = const_bar(2);
 /// ```
 #[macro_export]
 macro_rules! build_assert {
diff --git a/rust/kernel/lib.rs b/rust/kernel/lib.rs
index f427cd3c8cce..d772713459a3 100644
--- a/rust/kernel/lib.rs
+++ b/rust/kernel/lib.rs
@@ -80,7 +80,6 @@
 #[cfg(CONFIG_BLOCK)]
 pub mod block;
 pub mod bug;
-#[doc(hidden)]
 pub mod build_assert;
 pub mod clk;
 #[cfg(CONFIG_CONFIGFS_FS)]
-- 
2.51.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 4/4] rust: make `build_assert` module the home of related macros
       [not found] <20260319121653.2975748-1-gary@kernel.org>
                   ` (2 preceding siblings ...)
  2026-03-19 12:16 ` [PATCH v3 3/4] rust: rework `build_assert!` documentation Gary Guo
@ 2026-03-19 12:16 ` Gary Guo
  2026-03-19 14:14   ` Danilo Krummrich
                     ` (4 more replies)
  3 siblings, 5 replies; 22+ messages in thread
From: Gary Guo @ 2026-03-19 12:16 UTC (permalink / raw)
  To: Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich, Alexandre Courbot, David Airlie, Simona Vetter,
	Abdiel Janulgue, Daniel Almeida, Robin Murphy, FUJITA Tomonori,
	Yury Norov, Will Deacon, Peter Zijlstra, Mark Rutland,
	Ingo Molnar, Waiman Long, Tamir Duberstein
  Cc: Yury Norov, rust-for-linux, nouveau, dri-devel, linux-kernel,
	driver-core, netdev

From: Gary Guo <gary@garyguo.net>

Given the macro scoping rules, all macros are rendered 3 times, in the
module, in the top-level of kernel crate, and in the prelude.

Add `#[doc(no_inline)]` to the prelude so it just shows up as re-export.
Add `#[doc(hidden)]` to the macro definition and `#[doc(inline)]` to the
re-export inside `build_assert` module so the top-level items are hidden.

Signed-off-by: Gary Guo <gary@garyguo.net>
---
 drivers/gpu/nova-core/bitfield.rs    |  4 ++--
 drivers/gpu/nova-core/num.rs         |  2 +-
 rust/kernel/build_assert.rs          | 19 ++++++++++++-------
 rust/kernel/dma.rs                   |  5 +++--
 rust/kernel/io/register.rs           | 19 ++++++++++++-------
 rust/kernel/io/resource.rs           |  2 +-
 rust/kernel/ioctl.rs                 |  2 +-
 rust/kernel/net/phy/reg.rs           |  8 +++++---
 rust/kernel/num/bounded.rs           |  2 +-
 rust/kernel/prelude.rs               |  3 ++-
 rust/kernel/sync/atomic/internal.rs  |  9 ++++++---
 rust/kernel/sync/atomic/predefine.rs |  2 +-
 rust/kernel/sync/locked_by.rs        |  2 +-
 rust/kernel/sync/refcount.rs         |  8 +++++---
 rust/kernel/xarray.rs                | 10 ++++++++--
 15 files changed, 61 insertions(+), 36 deletions(-)

diff --git a/drivers/gpu/nova-core/bitfield.rs b/drivers/gpu/nova-core/bitfield.rs
index 16e143658c51..c3e1235ad7fb 100644
--- a/drivers/gpu/nova-core/bitfield.rs
+++ b/drivers/gpu/nova-core/bitfield.rs
@@ -170,7 +170,7 @@ impl $name {
     (@check_field_bounds $hi:tt:$lo:tt $field:ident as bool) => {
         #[allow(clippy::eq_op)]
         const _: () = {
-            ::kernel::build_assert!(
+            ::kernel::build_assert::build_assert!(
                 $hi == $lo,
                 concat!("boolean field `", stringify!($field), "` covers more than one bit")
             );
@@ -181,7 +181,7 @@ impl $name {
     (@check_field_bounds $hi:tt:$lo:tt $field:ident as $type:tt) => {
         #[allow(clippy::eq_op)]
         const _: () = {
-            ::kernel::build_assert!(
+            ::kernel::build_assert::build_assert!(
                 $hi >= $lo,
                 concat!("field `", stringify!($field), "`'s MSB is smaller than its LSB")
             );
diff --git a/drivers/gpu/nova-core/num.rs b/drivers/gpu/nova-core/num.rs
index c952a834e662..329169b21b28 100644
--- a/drivers/gpu/nova-core/num.rs
+++ b/drivers/gpu/nova-core/num.rs
@@ -49,7 +49,7 @@ macro_rules! impl_safe_as {
             #[allow(unused)]
             #[inline(always)]
             pub(crate) const fn [<$from _as_ $into>](value: $from) -> $into {
-                kernel::static_assert!(size_of::<$into>() >= size_of::<$from>());
+                ::kernel::build_assert::static_assert!(size_of::<$into>() >= size_of::<$from>());
 
                 value as $into
             }
diff --git a/rust/kernel/build_assert.rs b/rust/kernel/build_assert.rs
index 726d0b76ca2b..11ac83e515ac 100644
--- a/rust/kernel/build_assert.rs
+++ b/rust/kernel/build_assert.rs
@@ -61,15 +61,16 @@
 //! undefined symbols and linker errors, it is not developer friendly to debug, so it is recommended
 //! to avoid it and prefer other two assertions where possible.
 
+#[doc(inline)]
 pub use crate::{
-    build_assert,
+    build_assert_macro as build_assert,
     build_error,
     const_assert,
     static_assert, //
 };
 
 #[doc(hidden)]
-pub use build_error::build_error;
+pub use build_error::build_error as build_error_fn;
 
 /// Static assert (i.e. compile-time assert).
 ///
@@ -105,6 +106,7 @@
 /// static_assert!(f(40) == 42, "f(x) must add 2 to the given input.");
 /// ```
 #[macro_export]
+#[doc(hidden)]
 macro_rules! static_assert {
     ($condition:expr $(,$arg:literal)?) => {
         const _: () = ::core::assert!($condition $(,$arg)?);
@@ -133,6 +135,7 @@ macro_rules! static_assert {
 /// }
 /// ```
 #[macro_export]
+#[doc(hidden)]
 macro_rules! const_assert {
     ($condition:expr $(,$arg:literal)?) => {
         const { ::core::assert!($condition $(,$arg)?) };
@@ -157,12 +160,13 @@ macro_rules! const_assert {
 /// // foo(usize::MAX); // Fails to compile.
 /// ```
 #[macro_export]
+#[doc(hidden)]
 macro_rules! build_error {
     () => {{
-        $crate::build_assert::build_error("")
+        $crate::build_assert::build_error_fn("")
     }};
     ($msg:expr) => {{
-        $crate::build_assert::build_error($msg)
+        $crate::build_assert::build_error_fn($msg)
     }};
 }
 
@@ -200,15 +204,16 @@ macro_rules! build_error {
 /// const _: () = const_bar(2);
 /// ```
 #[macro_export]
-macro_rules! build_assert {
+#[doc(hidden)]
+macro_rules! build_assert_macro {
     ($cond:expr $(,)?) => {{
         if !$cond {
-            $crate::build_assert::build_error(concat!("assertion failed: ", stringify!($cond)));
+            $crate::build_assert::build_error_fn(concat!("assertion failed: ", stringify!($cond)));
         }
     }};
     ($cond:expr, $msg:expr) => {{
         if !$cond {
-            $crate::build_assert::build_error($msg);
+            $crate::build_assert::build_error_fn($msg);
         }
     }};
 }
diff --git a/rust/kernel/dma.rs b/rust/kernel/dma.rs
index a396f8435739..f209fb334c85 100644
--- a/rust/kernel/dma.rs
+++ b/rust/kernel/dma.rs
@@ -5,12 +5,13 @@
 //! C header: [`include/linux/dma-mapping.h`](srctree/include/linux/dma-mapping.h)
 
 use crate::{
-    bindings, build_assert, device,
+    bindings,
+    device,
     device::{Bound, Core},
     error::{to_result, Result},
     prelude::*,
     sync::aref::ARef,
-    transmute::{AsBytes, FromBytes},
+    transmute::{AsBytes, FromBytes}, //
 };
 use core::ptr::NonNull;
 
diff --git a/rust/kernel/io/register.rs b/rust/kernel/io/register.rs
index abc49926abfe..2133d3e62fd5 100644
--- a/rust/kernel/io/register.rs
+++ b/rust/kernel/io/register.rs
@@ -108,9 +108,10 @@
 
 use core::marker::PhantomData;
 
-use crate::io::IoLoc;
-
-use kernel::build_assert;
+use crate::{
+    build_assert::build_assert,
+    io::IoLoc, //
+};
 
 /// Trait implemented by all registers.
 pub trait Register: Sized {
@@ -872,7 +873,7 @@ macro_rules! register {
         @reg $(#[$attr:meta])* $vis:vis $name:ident ($storage:ty)
             [ $size:expr, stride = $stride:expr ] @ $offset:literal { $($fields:tt)* }
     ) => {
-        ::kernel::static_assert!(::core::mem::size_of::<$storage>() <= $stride);
+        $crate::build_assert::static_assert!(::core::mem::size_of::<$storage>() <= $stride);
 
         $crate::register!(@bitfield $(#[$attr])* $vis struct $name($storage) { $($fields)* });
         $crate::register!(@io_base $name($storage) @ $offset);
@@ -895,7 +896,9 @@ macro_rules! register {
         @reg $(#[$attr:meta])* $vis:vis $name:ident ($storage:ty) => $alias:ident [ $idx:expr ]
             { $($fields:tt)* }
     ) => {
-        ::kernel::static_assert!($idx < <$alias as $crate::io::register::RegisterArray>::SIZE);
+        $crate::build_assert::static_assert!(
+            $idx < <$alias as $crate::io::register::RegisterArray>::SIZE
+        );
 
         $crate::register!(@bitfield $(#[$attr])* $vis struct $name($storage) { $($fields)* });
         $crate::register!(
@@ -912,7 +915,7 @@ macro_rules! register {
             [ $size:expr, stride = $stride:expr ]
             @ $base:ident + $offset:literal { $($fields:tt)* }
     ) => {
-        ::kernel::static_assert!(::core::mem::size_of::<$storage>() <= $stride);
+        $crate::build_assert::static_assert!(::core::mem::size_of::<$storage>() <= $stride);
 
         $crate::register!(@bitfield $(#[$attr])* $vis struct $name($storage) { $($fields)* });
         $crate::register!(@io_base $name($storage) @ $offset);
@@ -938,7 +941,9 @@ macro_rules! register {
         @reg $(#[$attr:meta])* $vis:vis $name:ident ($storage:ty)
             => $base:ident + $alias:ident [ $idx:expr ] { $($fields:tt)* }
     ) => {
-        ::kernel::static_assert!($idx < <$alias as $crate::io::register::RegisterArray>::SIZE);
+        $crate::build_assert::static_assert!(
+            $idx < <$alias as $crate::io::register::RegisterArray>::SIZE
+        );
 
         $crate::register!(@bitfield $(#[$attr])* $vis struct $name($storage) { $($fields)* });
         $crate::register!(
diff --git a/rust/kernel/io/resource.rs b/rust/kernel/io/resource.rs
index b7ac9faf141d..17b0c174cfc5 100644
--- a/rust/kernel/io/resource.rs
+++ b/rust/kernel/io/resource.rs
@@ -229,7 +229,7 @@ impl Flags {
     // Always inline to optimize out error path of `build_assert`.
     #[inline(always)]
     const fn new(value: u32) -> Self {
-        crate::build_assert!(value as u64 <= c_ulong::MAX as u64);
+        build_assert!(value as u64 <= c_ulong::MAX as u64);
         Flags(value as c_ulong)
     }
 }
diff --git a/rust/kernel/ioctl.rs b/rust/kernel/ioctl.rs
index 2fc7662339e5..5bb5b48cf949 100644
--- a/rust/kernel/ioctl.rs
+++ b/rust/kernel/ioctl.rs
@@ -6,7 +6,7 @@
 
 #![expect(non_snake_case)]
 
-use crate::build_assert;
+use crate::build_assert::build_assert;
 
 /// Build an ioctl number, analogous to the C macro of the same name.
 #[inline(always)]
diff --git a/rust/kernel/net/phy/reg.rs b/rust/kernel/net/phy/reg.rs
index a7db0064cb7d..80e22c264ea8 100644
--- a/rust/kernel/net/phy/reg.rs
+++ b/rust/kernel/net/phy/reg.rs
@@ -9,9 +9,11 @@
 //! defined in IEEE 802.3.
 
 use super::Device;
-use crate::build_assert;
-use crate::error::*;
-use crate::uapi;
+use crate::{
+    build_assert::build_assert,
+    error::*,
+    uapi, //
+};
 
 mod private {
     /// Marker that a trait cannot be implemented outside of this crate
diff --git a/rust/kernel/num/bounded.rs b/rust/kernel/num/bounded.rs
index f9f90d6ec482..dafe77782d79 100644
--- a/rust/kernel/num/bounded.rs
+++ b/rust/kernel/num/bounded.rs
@@ -364,7 +364,7 @@ pub fn try_new(value: T) -> Option<Self> {
     // Always inline to optimize out error path of `build_assert`.
     #[inline(always)]
     pub fn from_expr(expr: T) -> Self {
-        crate::build_assert!(
+        crate::build_assert::build_assert!(
             fits_within(expr, N),
             "Requested value larger than maximal representable value."
         );
diff --git a/rust/kernel/prelude.rs b/rust/kernel/prelude.rs
index 6a54597fa0a2..baf8f6a94ea1 100644
--- a/rust/kernel/prelude.rs
+++ b/rust/kernel/prelude.rs
@@ -29,7 +29,8 @@
 
 pub use pin_init::{init, pin_data, pin_init, pinned_drop, InPlaceWrite, Init, PinInit, Zeroable};
 
-pub use super::{
+#[doc(no_inline)]
+pub use crate::build_assert::{
     build_assert,
     build_error,
     const_assert,
diff --git a/rust/kernel/sync/atomic/internal.rs b/rust/kernel/sync/atomic/internal.rs
index ad810c2172ec..9c8a7a203abd 100644
--- a/rust/kernel/sync/atomic/internal.rs
+++ b/rust/kernel/sync/atomic/internal.rs
@@ -4,8 +4,11 @@
 //!
 //! Provides 1:1 mapping to the C atomic operations.
 
-use crate::bindings;
-use crate::macros::paste;
+use crate::{
+    bindings,
+    build_assert::static_assert,
+    macros::paste, //
+};
 use core::cell::UnsafeCell;
 use ffi::c_void;
 
@@ -46,7 +49,7 @@ pub trait AtomicImpl: Sized + Copy + private::Sealed {
 // In the future when a CONFIG_ARCH_SUPPORTS_ATOMIC_RMW=n architecture plans to support Rust, the
 // load/store helpers that guarantee atomicity against RmW operations (usually via a lock) need to
 // be added.
-crate::static_assert!(
+static_assert!(
     cfg!(CONFIG_ARCH_SUPPORTS_ATOMIC_RMW),
     "The current implementation of atomic i8/i16/ptr relies on the architecure being \
     ARCH_SUPPORTS_ATOMIC_RMW"
diff --git a/rust/kernel/sync/atomic/predefine.rs b/rust/kernel/sync/atomic/predefine.rs
index 1d53834fcb12..2c92de040f03 100644
--- a/rust/kernel/sync/atomic/predefine.rs
+++ b/rust/kernel/sync/atomic/predefine.rs
@@ -2,7 +2,7 @@
 
 //! Pre-defined atomic types
 
-use crate::static_assert;
+use crate::prelude::*;
 use core::mem::{align_of, size_of};
 use ffi::c_void;
 
diff --git a/rust/kernel/sync/locked_by.rs b/rust/kernel/sync/locked_by.rs
index 61f100a45b35..fb4a1430b3b4 100644
--- a/rust/kernel/sync/locked_by.rs
+++ b/rust/kernel/sync/locked_by.rs
@@ -3,7 +3,7 @@
 //! A wrapper for data protected by a lock that does not wrap it.
 
 use super::{lock::Backend, lock::Lock};
-use crate::build_assert;
+use crate::build_assert::build_assert;
 use core::{cell::UnsafeCell, mem::size_of, ptr};
 
 /// Allows access to some data to be serialised by a lock that does not wrap it.
diff --git a/rust/kernel/sync/refcount.rs b/rust/kernel/sync/refcount.rs
index 6c7ae8b05a0b..23a5d201f343 100644
--- a/rust/kernel/sync/refcount.rs
+++ b/rust/kernel/sync/refcount.rs
@@ -4,9 +4,11 @@
 //!
 //! C header: [`include/linux/refcount.h`](srctree/include/linux/refcount.h)
 
-use crate::build_assert;
-use crate::sync::atomic::Atomic;
-use crate::types::Opaque;
+use crate::{
+    build_assert::build_assert,
+    sync::atomic::Atomic,
+    types::Opaque, //
+};
 
 /// Atomic reference counter.
 ///
diff --git a/rust/kernel/xarray.rs b/rust/kernel/xarray.rs
index a49d6db28845..8fc4eab02642 100644
--- a/rust/kernel/xarray.rs
+++ b/rust/kernel/xarray.rs
@@ -5,10 +5,16 @@
 //! C header: [`include/linux/xarray.h`](srctree/include/linux/xarray.h)
 
 use crate::{
-    alloc, bindings, build_assert,
+    alloc,
+    bindings,
+    build_assert::build_assert,
     error::{Error, Result},
     ffi::c_void,
-    types::{ForeignOwnable, NotThreadSafe, Opaque},
+    types::{
+        ForeignOwnable,
+        NotThreadSafe,
+        Opaque, //
+    }, //
 };
 use core::{iter, marker::PhantomData, pin::Pin, ptr::NonNull};
 use pin_init::{pin_data, pin_init, pinned_drop, PinInit};
-- 
2.51.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 1/4] rust: move `static_assert` into `build_assert`
  2026-03-19 12:16 ` [PATCH v3 1/4] rust: move `static_assert` into `build_assert` Gary Guo
@ 2026-03-19 14:09   ` Alice Ryhl
  0 siblings, 0 replies; 22+ messages in thread
From: Alice Ryhl @ 2026-03-19 14:09 UTC (permalink / raw)
  To: Gary Guo
  Cc: Miguel Ojeda, Boqun Feng, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Trevor Gross, Danilo Krummrich, Yury Norov,
	rust-for-linux, linux-kernel

On Thu, Mar 19, 2026 at 12:16:45PM +0000, Gary Guo wrote:
> From: Gary Guo <gary@garyguo.net>
> 
> Conceptually, `static_assert` is also a build-time assertion that occurs
> earlier in the pipeline. Consolidate the implementation so that we can use
> this as the canonical place to add more useful build-time assertions.
> 
> Reviewed-by: Yury Norov <ynorov@nvidia.com>
> Signed-off-by: Gary Guo <gary@garyguo.net>

Reviewed-by: Alice Ryhl <aliceryhl@google.com>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 2/4] rust: add `const_assert!` macro
  2026-03-19 12:16 ` [PATCH v3 2/4] rust: add `const_assert!` macro Gary Guo
@ 2026-03-19 14:12   ` Alice Ryhl
  2026-03-19 14:26     ` Gary Guo
  2026-03-21 13:05   ` Alexandre Courbot
  1 sibling, 1 reply; 22+ messages in thread
From: Alice Ryhl @ 2026-03-19 14:12 UTC (permalink / raw)
  To: Gary Guo
  Cc: Miguel Ojeda, Boqun Feng, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Trevor Gross, Danilo Krummrich,
	Alexandre Courbot, Yury Norov, Nathan Chancellor, Nicolas Schier,
	Yury Norov, rust-for-linux, linux-kernel, linux-kbuild

On Thu, Mar 19, 2026 at 12:16:46PM +0000, Gary Guo wrote:
> From: Gary Guo <gary@garyguo.net>
> 
> 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: Alice Ryhl <aliceryhl@google.com>

It may be worth to mention in docs that const_assert! may only be
checked if the function it appears in has a caller. Whereas
static_assert! is always checked no matter what.

Alice

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 4/4] rust: make `build_assert` module the home of related macros
  2026-03-19 12:16 ` [PATCH v3 4/4] rust: make `build_assert` module the home of related macros Gary Guo
@ 2026-03-19 14:14   ` Danilo Krummrich
  2026-03-19 14:33   ` Alice Ryhl
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 22+ messages in thread
From: Danilo Krummrich @ 2026-03-19 14:14 UTC (permalink / raw)
  To: Gary Guo, Miguel Ojeda
  Cc: Boqun Feng, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Alice Ryhl, Trevor Gross, Alexandre Courbot, David Airlie,
	Simona Vetter, Abdiel Janulgue, Daniel Almeida, Robin Murphy,
	FUJITA Tomonori, Yury Norov, Will Deacon, Peter Zijlstra,
	Mark Rutland, Ingo Molnar, Waiman Long, Tamir Duberstein,
	Yury Norov, rust-for-linux, nouveau, dri-devel, linux-kernel,
	driver-core, netdev

On 3/19/26 1:16 PM, Gary Guo wrote:
>  drivers/gpu/nova-core/bitfield.rs    |  4 ++--
>  drivers/gpu/nova-core/num.rs         |  2 +-
>  rust/kernel/dma.rs                   |  5 +++--
>  rust/kernel/io/register.rs           | 19 ++++++++++++-------
>  rust/kernel/io/resource.rs           |  2 +-

Acked-by: Danilo Krummrich <dakr@kernel.org>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 3/4] rust: rework `build_assert!` documentation
  2026-03-19 12:16 ` [PATCH v3 3/4] rust: rework `build_assert!` documentation Gary Guo
@ 2026-03-19 14:17   ` Alice Ryhl
  2026-03-21 13:05   ` Alexandre Courbot
  1 sibling, 0 replies; 22+ messages in thread
From: Alice Ryhl @ 2026-03-19 14:17 UTC (permalink / raw)
  To: Gary Guo
  Cc: Miguel Ojeda, Boqun Feng, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Trevor Gross, Danilo Krummrich, Yury Norov,
	rust-for-linux, linux-kernel

On Thu, Mar 19, 2026 at 12:16:47PM +0000, Gary Guo wrote:
> From: Gary Guo <gary@garyguo.net>
> 
> Add a detailed comparison and recommendation of the three types of
> build-time assertion macro as module documentation (and un-hide the module
> to render them).
> 
> The documentation on the macro themselves are simplified to only cover the
> scenarios where they should be used; links to the module documentation is
> added instead.
> 
> Reviewed-by: Yury Norov <ynorov@nvidia.com>
> Signed-off-by: Gary Guo <gary@garyguo.net>

Reviewed-by: Alice Ryhl <aliceryhl@google.com>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 2/4] rust: add `const_assert!` macro
  2026-03-19 14:12   ` Alice Ryhl
@ 2026-03-19 14:26     ` Gary Guo
  2026-03-19 14:34       ` Alice Ryhl
  0 siblings, 1 reply; 22+ messages in thread
From: Gary Guo @ 2026-03-19 14:26 UTC (permalink / raw)
  To: Alice Ryhl, Gary Guo
  Cc: Miguel Ojeda, Boqun Feng, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Trevor Gross, Danilo Krummrich,
	Alexandre Courbot, Yury Norov, Nathan Chancellor, Nicolas Schier,
	Yury Norov, rust-for-linux, linux-kernel, linux-kbuild

On Thu Mar 19, 2026 at 2:12 PM GMT, Alice Ryhl wrote:
> On Thu, Mar 19, 2026 at 12:16:46PM +0000, Gary Guo wrote:
>> From: Gary Guo <gary@garyguo.net>
>> 
>> 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: Alice Ryhl <aliceryhl@google.com>
>
> It may be worth to mention in docs that const_assert! may only be
> checked if the function it appears in has a caller. Whereas
> static_assert! is always checked no matter what.
>
> Alice

I explained this in patch 3 on why `static_assert!` is preferred over
`const_assert!`. Given that we recommend `const_assert!` only when it refers to
generics, the check is inherently tied to a specific instance anyway, so I don't
think it needs to be mentioned in the item doc.

Best,
Gary



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 4/4] rust: make `build_assert` module the home of related macros
  2026-03-19 12:16 ` [PATCH v3 4/4] rust: make `build_assert` module the home of related macros Gary Guo
  2026-03-19 14:14   ` Danilo Krummrich
@ 2026-03-19 14:33   ` Alice Ryhl
  2026-03-21 13:05   ` Alexandre Courbot
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 22+ messages in thread
From: Alice Ryhl @ 2026-03-19 14:33 UTC (permalink / raw)
  To: Gary Guo
  Cc: Miguel Ojeda, Boqun Feng, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Trevor Gross, Danilo Krummrich,
	Alexandre Courbot, David Airlie, Simona Vetter, Abdiel Janulgue,
	Daniel Almeida, Robin Murphy, FUJITA Tomonori, Yury Norov,
	Will Deacon, Peter Zijlstra, Mark Rutland, Ingo Molnar,
	Waiman Long, Tamir Duberstein, Yury Norov, rust-for-linux,
	nouveau, dri-devel, linux-kernel, driver-core, netdev

On Thu, Mar 19, 2026 at 12:16:48PM +0000, Gary Guo wrote:
> From: Gary Guo <gary@garyguo.net>
> 
> Given the macro scoping rules, all macros are rendered 3 times, in the
> module, in the top-level of kernel crate, and in the prelude.
> 
> Add `#[doc(no_inline)]` to the prelude so it just shows up as re-export.
> Add `#[doc(hidden)]` to the macro definition and `#[doc(inline)]` to the
> re-export inside `build_assert` module so the top-level items are hidden.
> 
> Signed-off-by: Gary Guo <gary@garyguo.net>

Reviewed-by: Alice Ryhl <aliceryhl@google.com>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 2/4] rust: add `const_assert!` macro
  2026-03-19 14:26     ` Gary Guo
@ 2026-03-19 14:34       ` Alice Ryhl
  0 siblings, 0 replies; 22+ messages in thread
From: Alice Ryhl @ 2026-03-19 14:34 UTC (permalink / raw)
  To: Gary Guo
  Cc: Miguel Ojeda, Boqun Feng, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Trevor Gross, Danilo Krummrich,
	Alexandre Courbot, Yury Norov, Nathan Chancellor, Nicolas Schier,
	Yury Norov, rust-for-linux, linux-kernel, linux-kbuild

On Thu, Mar 19, 2026 at 02:26:06PM +0000, Gary Guo wrote:
> On Thu Mar 19, 2026 at 2:12 PM GMT, Alice Ryhl wrote:
> > On Thu, Mar 19, 2026 at 12:16:46PM +0000, Gary Guo wrote:
> >> From: Gary Guo <gary@garyguo.net>
> >> 
> >> 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: Alice Ryhl <aliceryhl@google.com>
> >
> > It may be worth to mention in docs that const_assert! may only be
> > checked if the function it appears in has a caller. Whereas
> > static_assert! is always checked no matter what.
> >
> > Alice
> 
> I explained this in patch 3 on why `static_assert!` is preferred over
> `const_assert!`. Given that we recommend `const_assert!` only when it refers to
> generics, the check is inherently tied to a specific instance anyway, so I don't
> think it needs to be mentioned in the item doc.

Ok.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 4/4] rust: make `build_assert` module the home of related macros
  2026-03-19 12:16 ` [PATCH v3 4/4] rust: make `build_assert` module the home of related macros Gary Guo
  2026-03-19 14:14   ` Danilo Krummrich
  2026-03-19 14:33   ` Alice Ryhl
@ 2026-03-21 13:05   ` Alexandre Courbot
  2026-03-21 13:32     ` Gary Guo
  2026-03-22 23:36   ` Miguel Ojeda
  2026-03-23  0:15   ` Tamir Duberstein
  4 siblings, 1 reply; 22+ messages in thread
From: Alexandre Courbot @ 2026-03-21 13:05 UTC (permalink / raw)
  To: Gary Guo
  Cc: Gary Guo, Miguel Ojeda, Boqun Feng, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich, David Airlie, Simona Vetter, Abdiel Janulgue,
	Daniel Almeida, Robin Murphy, FUJITA Tomonori, Yury Norov,
	Will Deacon, Peter Zijlstra, Mark Rutland, Ingo Molnar,
	Waiman Long, Tamir Duberstein, Yury Norov, rust-for-linux,
	nouveau, dri-devel, linux-kernel, driver-core, netdev

On Thu Mar 19, 2026 at 9:16 PM JST, Gary Guo wrote:
> From: Gary Guo <gary@garyguo.net>
>
> Given the macro scoping rules, all macros are rendered 3 times, in the
> module, in the top-level of kernel crate, and in the prelude.
>
> Add `#[doc(no_inline)]` to the prelude so it just shows up as re-export.
> Add `#[doc(hidden)]` to the macro definition and `#[doc(inline)]` to the
> re-export inside `build_assert` module so the top-level items are hidden.
>
> Signed-off-by: Gary Guo <gary@garyguo.net>
> ---
>  drivers/gpu/nova-core/bitfield.rs    |  4 ++--
>  drivers/gpu/nova-core/num.rs         |  2 +-
>  rust/kernel/build_assert.rs          | 19 ++++++++++++-------
>  rust/kernel/dma.rs                   |  5 +++--
>  rust/kernel/io/register.rs           | 19 ++++++++++++-------
>  rust/kernel/io/resource.rs           |  2 +-
>  rust/kernel/ioctl.rs                 |  2 +-
>  rust/kernel/net/phy/reg.rs           |  8 +++++---
>  rust/kernel/num/bounded.rs           |  2 +-
>  rust/kernel/prelude.rs               |  3 ++-
>  rust/kernel/sync/atomic/internal.rs  |  9 ++++++---
>  rust/kernel/sync/atomic/predefine.rs |  2 +-
>  rust/kernel/sync/locked_by.rs        |  2 +-
>  rust/kernel/sync/refcount.rs         |  8 +++++---
>  rust/kernel/xarray.rs                | 10 ++++++++--
>  15 files changed, 61 insertions(+), 36 deletions(-)
>
> diff --git a/drivers/gpu/nova-core/bitfield.rs b/drivers/gpu/nova-core/bitfield.rs
> index 16e143658c51..c3e1235ad7fb 100644
> --- a/drivers/gpu/nova-core/bitfield.rs
> +++ b/drivers/gpu/nova-core/bitfield.rs
> @@ -170,7 +170,7 @@ impl $name {
>      (@check_field_bounds $hi:tt:$lo:tt $field:ident as bool) => {
>          #[allow(clippy::eq_op)]
>          const _: () = {
> -            ::kernel::build_assert!(
> +            ::kernel::build_assert::build_assert!(

Given that the `build_assert` module now hosts 3 different assert
macros, have we considered renaming it to just `assert`? Otherwise the
naming implies that it is more connected to the `build_assert` macro
than the others, which doesn't seem to be true.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 2/4] rust: add `const_assert!` macro
  2026-03-19 12:16 ` [PATCH v3 2/4] rust: add `const_assert!` macro Gary Guo
  2026-03-19 14:12   ` Alice Ryhl
@ 2026-03-21 13:05   ` Alexandre Courbot
  1 sibling, 0 replies; 22+ messages in thread
From: Alexandre Courbot @ 2026-03-21 13:05 UTC (permalink / raw)
  To: Gary Guo
  Cc: Gary Guo, Miguel Ojeda, Boqun Feng, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich, Yury Norov, Nathan Chancellor, Nicolas Schier,
	Yury Norov, rust-for-linux, linux-kernel, linux-kbuild

On Thu Mar 19, 2026 at 9:16 PM JST, Gary Guo wrote:
> From: Gary Guo <gary@garyguo.net>
>
> 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>
> ---
>  rust/kernel/build_assert.rs | 24 ++++++++++++++++++++++++
>  rust/kernel/num/bounded.rs  | 24 +++++++++---------------
>  rust/kernel/prelude.rs      |  7 ++++++-
>  rust/kernel/ptr.rs          | 12 ++++++------
>  scripts/Makefile.build      |  5 +++--

I'd split the update of users to the new version into dedicated patches,
but other than that,

Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 3/4] rust: rework `build_assert!` documentation
  2026-03-19 12:16 ` [PATCH v3 3/4] rust: rework `build_assert!` documentation Gary Guo
  2026-03-19 14:17   ` Alice Ryhl
@ 2026-03-21 13:05   ` Alexandre Courbot
  1 sibling, 0 replies; 22+ messages in thread
From: Alexandre Courbot @ 2026-03-21 13:05 UTC (permalink / raw)
  To: Gary Guo
  Cc: Gary Guo, Miguel Ojeda, Boqun Feng, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich, Yury Norov, rust-for-linux, linux-kernel

On Thu Mar 19, 2026 at 9:16 PM JST, Gary Guo wrote:
> From: Gary Guo <gary@garyguo.net>
>
> Add a detailed comparison and recommendation of the three types of
> build-time assertion macro as module documentation (and un-hide the module
> to render them).
>
> The documentation on the macro themselves are simplified to only cover the
> scenarios where they should be used; links to the module documentation is
> added instead.
>
> Reviewed-by: Yury Norov <ynorov@nvidia.com>
> Signed-off-by: Gary Guo <gary@garyguo.net>

That's a great improvement over the documentation, makes the use
scenarios crytal-clear.

Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 4/4] rust: make `build_assert` module the home of related macros
  2026-03-21 13:05   ` Alexandre Courbot
@ 2026-03-21 13:32     ` Gary Guo
  2026-03-21 13:41       ` Miguel Ojeda
  0 siblings, 1 reply; 22+ messages in thread
From: Gary Guo @ 2026-03-21 13:32 UTC (permalink / raw)
  To: Alexandre Courbot, Gary Guo
  Cc: Gary Guo, Miguel Ojeda, Boqun Feng, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich, David Airlie, Simona Vetter, Abdiel Janulgue,
	Daniel Almeida, Robin Murphy, FUJITA Tomonori, Yury Norov,
	Will Deacon, Peter Zijlstra, Mark Rutland, Ingo Molnar,
	Waiman Long, Tamir Duberstein, Yury Norov, rust-for-linux,
	nouveau, dri-devel, linux-kernel, driver-core, netdev

On Sat Mar 21, 2026 at 1:05 PM GMT, Alexandre Courbot wrote:
> On Thu Mar 19, 2026 at 9:16 PM JST, Gary Guo wrote:
>> From: Gary Guo <gary@garyguo.net>
>>
>> Given the macro scoping rules, all macros are rendered 3 times, in the
>> module, in the top-level of kernel crate, and in the prelude.
>>
>> Add `#[doc(no_inline)]` to the prelude so it just shows up as re-export.
>> Add `#[doc(hidden)]` to the macro definition and `#[doc(inline)]` to the
>> re-export inside `build_assert` module so the top-level items are hidden.
>>
>> Signed-off-by: Gary Guo <gary@garyguo.net>
>> ---
>>  drivers/gpu/nova-core/bitfield.rs    |  4 ++--
>>  drivers/gpu/nova-core/num.rs         |  2 +-
>>  rust/kernel/build_assert.rs          | 19 ++++++++++++-------
>>  rust/kernel/dma.rs                   |  5 +++--
>>  rust/kernel/io/register.rs           | 19 ++++++++++++-------
>>  rust/kernel/io/resource.rs           |  2 +-
>>  rust/kernel/ioctl.rs                 |  2 +-
>>  rust/kernel/net/phy/reg.rs           |  8 +++++---
>>  rust/kernel/num/bounded.rs           |  2 +-
>>  rust/kernel/prelude.rs               |  3 ++-
>>  rust/kernel/sync/atomic/internal.rs  |  9 ++++++---
>>  rust/kernel/sync/atomic/predefine.rs |  2 +-
>>  rust/kernel/sync/locked_by.rs        |  2 +-
>>  rust/kernel/sync/refcount.rs         |  8 +++++---
>>  rust/kernel/xarray.rs                | 10 ++++++++--
>>  15 files changed, 61 insertions(+), 36 deletions(-)
>>
>> diff --git a/drivers/gpu/nova-core/bitfield.rs b/drivers/gpu/nova-core/bitfield.rs
>> index 16e143658c51..c3e1235ad7fb 100644
>> --- a/drivers/gpu/nova-core/bitfield.rs
>> +++ b/drivers/gpu/nova-core/bitfield.rs
>> @@ -170,7 +170,7 @@ impl $name {
>>      (@check_field_bounds $hi:tt:$lo:tt $field:ident as bool) => {
>>          #[allow(clippy::eq_op)]
>>          const _: () = {
>> -            ::kernel::build_assert!(
>> +            ::kernel::build_assert::build_assert!(
>
> Given that the `build_assert` module now hosts 3 different assert
> macros, have we considered renaming it to just `assert`? Otherwise the
> naming implies that it is more connected to the `build_assert` macro
> than the others, which doesn't seem to be true.

I personally view them all as variants of BUILD_BUG_ON, hence the name is
`build_assert`. I thought about `assert`, but to me that feels like it's going
to host runtime assertions.

I won't be surprised if we're going to have `assert` module in the future to
host families of

    assert!()
    warn_on!()
    unsafe { assume!() }
    ensure!()

etc..

Best,
Gary

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 4/4] rust: make `build_assert` module the home of related macros
  2026-03-21 13:32     ` Gary Guo
@ 2026-03-21 13:41       ` Miguel Ojeda
  0 siblings, 0 replies; 22+ messages in thread
From: Miguel Ojeda @ 2026-03-21 13:41 UTC (permalink / raw)
  To: Gary Guo
  Cc: Alexandre Courbot, Gary Guo, Miguel Ojeda, Boqun Feng,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, David Airlie, Simona Vetter,
	Abdiel Janulgue, Daniel Almeida, Robin Murphy, FUJITA Tomonori,
	Yury Norov, Will Deacon, Peter Zijlstra, Mark Rutland,
	Ingo Molnar, Waiman Long, Tamir Duberstein, Yury Norov,
	rust-for-linux, nouveau, dri-devel, linux-kernel, driver-core,
	netdev

On Sat, Mar 21, 2026 at 2:32 PM Gary Guo <gary@garyguo.net> wrote:
>
> I personally view them all as variants of BUILD_BUG_ON, hence the name is
> `build_assert`. I thought about `assert`, but to me that feels like it's going
> to host runtime assertions.
>
> I won't be surprised if we're going to have `assert` module in the future to
> host families of
>
>     assert!()
>     warn_on!()
>     unsafe { assume!() }
>     ensure!()
>
> etc..

We also have now `unsafe_precondition_assert` in the `safety` module
which is essentially a `debug_assert` at least for now, which could
potentially be moved too.

Most of these (both build time and runtime ones) should be in the
prelude anyway, so they should be easy to reorganize.

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 4/4] rust: make `build_assert` module the home of related macros
  2026-03-19 12:16 ` [PATCH v3 4/4] rust: make `build_assert` module the home of related macros Gary Guo
                     ` (2 preceding siblings ...)
  2026-03-21 13:05   ` Alexandre Courbot
@ 2026-03-22 23:36   ` Miguel Ojeda
  2026-03-23  1:08     ` Alexandre Courbot
  2026-03-26 12:09     ` FUJITA Tomonori
  2026-03-23  0:15   ` Tamir Duberstein
  4 siblings, 2 replies; 22+ messages in thread
From: Miguel Ojeda @ 2026-03-22 23:36 UTC (permalink / raw)
  To: Gary Guo, FUJITA Tomonori, Alexandre Courbot, Boqun Feng,
	Tamir Duberstein, Andreas Hindborg
  Cc: Miguel Ojeda, Boqun Feng, Björn Roy Baron, Benno Lossin,
	Alice Ryhl, Trevor Gross, Danilo Krummrich, David Airlie,
	Simona Vetter, Abdiel Janulgue, Daniel Almeida, Robin Murphy,
	Yury Norov, Will Deacon, Peter Zijlstra, Mark Rutland,
	Ingo Molnar, Waiman Long, Yury Norov, rust-for-linux, nouveau,
	dri-devel, linux-kernel, driver-core, netdev

On Thu, Mar 19, 2026 at 1:17 PM Gary Guo <gary@kernel.org> wrote:
>
>  rust/kernel/net/phy/reg.rs           |  8 +++++---

Tomonori: are you OK with these changes?

>  rust/kernel/num/bounded.rs           |  2 +-

Alexandre: are you OK with these changes?

>  rust/kernel/sync/atomic/internal.rs  |  9 ++++++---
>  rust/kernel/sync/atomic/predefine.rs |  2 +-
>  rust/kernel/sync/locked_by.rs        |  2 +-
>  rust/kernel/sync/refcount.rs         |  8 +++++---

Boqun: are you OK with these changes?

>  rust/kernel/xarray.rs                | 10 ++++++++--

Tamir, Andreas: are you OK with these changes?

> -    transmute::{AsBytes, FromBytes},
> +    transmute::{AsBytes, FromBytes}, //

Nit: We should take the chance to expand this.

Thanks all!

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 4/4] rust: make `build_assert` module the home of related macros
  2026-03-19 12:16 ` [PATCH v3 4/4] rust: make `build_assert` module the home of related macros Gary Guo
                     ` (3 preceding siblings ...)
  2026-03-22 23:36   ` Miguel Ojeda
@ 2026-03-23  0:15   ` Tamir Duberstein
  4 siblings, 0 replies; 22+ messages in thread
From: Tamir Duberstein @ 2026-03-23  0:15 UTC (permalink / raw)
  To: Gary Guo
  Cc: Miguel Ojeda, Boqun Feng, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich,
	Alexandre Courbot, David Airlie, Simona Vetter, Abdiel Janulgue,
	Daniel Almeida, Robin Murphy, FUJITA Tomonori, Yury Norov,
	Will Deacon, Peter Zijlstra, Mark Rutland, Ingo Molnar,
	Waiman Long, Yury Norov, rust-for-linux, nouveau, dri-devel,
	linux-kernel, driver-core, netdev

On Thu, Mar 19, 2026 at 8:17 AM Gary Guo <gary@kernel.org> wrote:
>
> From: Gary Guo <gary@garyguo.net>
>
> Given the macro scoping rules, all macros are rendered 3 times, in the
> module, in the top-level of kernel crate, and in the prelude.
>
> Add `#[doc(no_inline)]` to the prelude so it just shows up as re-export.
> Add `#[doc(hidden)]` to the macro definition and `#[doc(inline)]` to the
> re-export inside `build_assert` module so the top-level items are hidden.
>
> Signed-off-by: Gary Guo <gary@garyguo.net>
> ---
>  drivers/gpu/nova-core/bitfield.rs    |  4 ++--
>  drivers/gpu/nova-core/num.rs         |  2 +-
>  rust/kernel/build_assert.rs          | 19 ++++++++++++-------
>  rust/kernel/dma.rs                   |  5 +++--
>  rust/kernel/io/register.rs           | 19 ++++++++++++-------
>  rust/kernel/io/resource.rs           |  2 +-
>  rust/kernel/ioctl.rs                 |  2 +-
>  rust/kernel/net/phy/reg.rs           |  8 +++++---
>  rust/kernel/num/bounded.rs           |  2 +-
>  rust/kernel/prelude.rs               |  3 ++-
>  rust/kernel/sync/atomic/internal.rs  |  9 ++++++---
>  rust/kernel/sync/atomic/predefine.rs |  2 +-
>  rust/kernel/sync/locked_by.rs        |  2 +-
>  rust/kernel/sync/refcount.rs         |  8 +++++---
>  rust/kernel/xarray.rs                | 10 ++++++++--

Acked-by: Tamir Duberstein <tamird@kernel.org>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 4/4] rust: make `build_assert` module the home of related macros
  2026-03-22 23:36   ` Miguel Ojeda
@ 2026-03-23  1:08     ` Alexandre Courbot
  2026-03-23  1:38       ` Miguel Ojeda
  2026-03-26 12:09     ` FUJITA Tomonori
  1 sibling, 1 reply; 22+ messages in thread
From: Alexandre Courbot @ 2026-03-23  1:08 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Gary Guo, FUJITA Tomonori, Boqun Feng, Tamir Duberstein,
	Andreas Hindborg, Miguel Ojeda, Boqun Feng, Björn Roy Baron,
	Benno Lossin, Alice Ryhl, Trevor Gross, Danilo Krummrich,
	David Airlie, Simona Vetter, Abdiel Janulgue, Daniel Almeida,
	Robin Murphy, Yury Norov, Will Deacon, Peter Zijlstra,
	Mark Rutland, Ingo Molnar, Waiman Long, Yury Norov,
	rust-for-linux, nouveau, dri-devel, linux-kernel, driver-core,
	netdev

On Mon Mar 23, 2026 at 8:36 AM JST, Miguel Ojeda wrote:
>>  rust/kernel/num/bounded.rs           |  2 +-
>
> Alexandre: are you OK with these changes?

Acked-by: Alexandre Courbot <acourbot@nvidia.com>

(sorry, assumed my Reviewed-by carried an implicit ack as well)

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 4/4] rust: make `build_assert` module the home of related macros
  2026-03-23  1:08     ` Alexandre Courbot
@ 2026-03-23  1:38       ` Miguel Ojeda
  2026-03-23  1:50         ` Alexandre Courbot
  0 siblings, 1 reply; 22+ messages in thread
From: Miguel Ojeda @ 2026-03-23  1:38 UTC (permalink / raw)
  To: Alexandre Courbot
  Cc: Gary Guo, FUJITA Tomonori, Boqun Feng, Tamir Duberstein,
	Andreas Hindborg, Miguel Ojeda, Boqun Feng, Björn Roy Baron,
	Benno Lossin, Alice Ryhl, Trevor Gross, Danilo Krummrich,
	David Airlie, Simona Vetter, Abdiel Janulgue, Daniel Almeida,
	Robin Murphy, Yury Norov, Will Deacon, Peter Zijlstra,
	Mark Rutland, Ingo Molnar, Waiman Long, Yury Norov,
	rust-for-linux, nouveau, dri-devel, linux-kernel, driver-core,
	netdev

On Mon, Mar 23, 2026 at 2:08 AM Alexandre Courbot <acourbot@nvidia.com> wrote:
>
> Acked-by: Alexandre Courbot <acourbot@nvidia.com>
>
> (sorry, assumed my Reviewed-by carried an implicit ack as well)

Ah, I saw your tag for #2 and #3, but not #4 (nor #1).

Did I miss it/them?

Thanks!

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 4/4] rust: make `build_assert` module the home of related macros
  2026-03-23  1:38       ` Miguel Ojeda
@ 2026-03-23  1:50         ` Alexandre Courbot
  0 siblings, 0 replies; 22+ messages in thread
From: Alexandre Courbot @ 2026-03-23  1:50 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Gary Guo, FUJITA Tomonori, Boqun Feng, Tamir Duberstein,
	Andreas Hindborg, Miguel Ojeda, Boqun Feng, Björn Roy Baron,
	Benno Lossin, Alice Ryhl, Trevor Gross, Danilo Krummrich,
	Simona Vetter, Abdiel Janulgue, Daniel Almeida, Robin Murphy,
	Yury Norov, Will Deacon, Peter Zijlstra, Mark Rutland,
	Ingo Molnar, Waiman Long, Yury Norov, rust-for-linux, nouveau,
	dri-devel, linux-kernel, driver-core, netdev

On Mon Mar 23, 2026 at 10:38 AM JST, Miguel Ojeda wrote:
> On Mon, Mar 23, 2026 at 2:08 AM Alexandre Courbot <acourbot@nvidia.com> wrote:
>>
>> Acked-by: Alexandre Courbot <acourbot@nvidia.com>
>>
>> (sorry, assumed my Reviewed-by carried an implicit ack as well)
>
> Ah, I saw your tag for #2 and #3, but not #4 (nor #1).
>
> Did I miss it/them?

You are correct and I will have some more morning caffeine. :) I had one
question but the patch looks good regardless, should have acked it
preemptively.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 4/4] rust: make `build_assert` module the home of related macros
  2026-03-22 23:36   ` Miguel Ojeda
  2026-03-23  1:08     ` Alexandre Courbot
@ 2026-03-26 12:09     ` FUJITA Tomonori
  1 sibling, 0 replies; 22+ messages in thread
From: FUJITA Tomonori @ 2026-03-26 12:09 UTC (permalink / raw)
  To: miguel.ojeda.sandonis
  Cc: gary, fujita.tomonori, acourbot, boqun.feng, tamird, a.hindborg,
	ojeda, boqun, bjorn3_gh, lossin, aliceryhl, tmgross, dakr,
	airlied, simona, abdiel.janulgue, daniel.almeida, robin.murphy,
	yury.norov, will, peterz, mark.rutland, mingo, longman, ynorov,
	rust-for-linux, nouveau, dri-devel, linux-kernel, driver-core,
	netdev

On Mon, 23 Mar 2026 00:36:52 +0100
Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> wrote:

> On Thu, Mar 19, 2026 at 1:17 PM Gary Guo <gary@kernel.org> wrote:
>>
>>  rust/kernel/net/phy/reg.rs           |  8 +++++---
> 
> Tomonori: are you OK with these changes?

Acked-by: FUJITA Tomonori <fujita.tomonori@gmail.com>


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2026-03-26 12:09 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20260319121653.2975748-1-gary@kernel.org>
2026-03-19 12:16 ` [PATCH v3 1/4] rust: move `static_assert` into `build_assert` Gary Guo
2026-03-19 14:09   ` Alice Ryhl
2026-03-19 12:16 ` [PATCH v3 2/4] rust: add `const_assert!` macro Gary Guo
2026-03-19 14:12   ` Alice Ryhl
2026-03-19 14:26     ` Gary Guo
2026-03-19 14:34       ` Alice Ryhl
2026-03-21 13:05   ` Alexandre Courbot
2026-03-19 12:16 ` [PATCH v3 3/4] rust: rework `build_assert!` documentation Gary Guo
2026-03-19 14:17   ` Alice Ryhl
2026-03-21 13:05   ` Alexandre Courbot
2026-03-19 12:16 ` [PATCH v3 4/4] rust: make `build_assert` module the home of related macros Gary Guo
2026-03-19 14:14   ` Danilo Krummrich
2026-03-19 14:33   ` Alice Ryhl
2026-03-21 13:05   ` Alexandre Courbot
2026-03-21 13:32     ` Gary Guo
2026-03-21 13:41       ` Miguel Ojeda
2026-03-22 23:36   ` Miguel Ojeda
2026-03-23  1:08     ` Alexandre Courbot
2026-03-23  1:38       ` Miguel Ojeda
2026-03-23  1:50         ` Alexandre Courbot
2026-03-26 12:09     ` FUJITA Tomonori
2026-03-23  0:15   ` Tamir Duberstein

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox