Re: [PATCH 1/3] rust: tests: drop 'use crate' in bitmap and atomic KUnit tests

From: David Gow

Date: Fri Apr 17 2026 - 05:09:32 EST


Le 17/04/2026 à 11:15 AM, Yury Norov a écrit :
The following patch makes usage of macros::kunit_tests crate conditional
on the corresponding configs. When the configs are disabled, compiler
warns on unused crate. So, embed it in unit test declaration.

Signed-off-by: Yury Norov <ynorov@xxxxxxxxxx>
---

Looks good to me!

Reviewed-by: David Gow <david@xxxxxxxxxxxx>

Cheers,
-- David

rust/kernel/bitmap.rs | 4 +---
rust/kernel/sync/atomic/predefine.rs | 4 +---
2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/rust/kernel/bitmap.rs b/rust/kernel/bitmap.rs
index 83d7dea99137..894043c9e460 100644
--- a/rust/kernel/bitmap.rs
+++ b/rust/kernel/bitmap.rs
@@ -499,9 +499,7 @@ pub fn next_zero_bit(&self, start: usize) -> Option<usize> {
}
}
-use macros::kunit_tests;
-
-#[kunit_tests(rust_kernel_bitmap)]
+#[macros::kunit_tests(rust_kernel_bitmap)]
mod tests {
use super::*;
use kernel::alloc::flags::GFP_KERNEL;
diff --git a/rust/kernel/sync/atomic/predefine.rs b/rust/kernel/sync/atomic/predefine.rs
index 1d53834fcb12..84fcd7cfcb73 100644
--- a/rust/kernel/sync/atomic/predefine.rs
+++ b/rust/kernel/sync/atomic/predefine.rs
@@ -154,9 +154,7 @@ fn rhs_into_delta(rhs: usize) -> isize_atomic_repr {
}
}
-use crate::macros::kunit_tests;
-
-#[kunit_tests(rust_atomics)]
+#[macros::kunit_tests(rust_atomics)]
mod tests {
use super::super::*;