diff mbox series

[v6,05/18] rust: kunit: refactor to use `&raw [const|mut]`

Message ID 20250418014143.888022-6-contact@antoniohickey.com
State New
Headers show
Series None | expand

Commit Message

Antonio Hickey April 18, 2025, 1:41 a.m. UTC
Replacing all occurrences of `addr_of!(place)` and `addr_of_mut!(place)`
with `&raw const place` and `&raw mut place` respectively.

This will allow us to reduce macro complexity, and improve consistency
with existing reference syntax as `&raw const`, `&raw mut` are similar
to `&`, `&mut` making it fit more naturally with other existing code.

Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: https://github.com/Rust-for-Linux/linux/issues/1148
Signed-off-by: Antonio Hickey <contact@antoniohickey.com>
---
 rust/kernel/kunit.rs | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/rust/kernel/kunit.rs b/rust/kernel/kunit.rs
index 1604fb6a5b1b..9f8165b15a37 100644
--- a/rust/kernel/kunit.rs
+++ b/rust/kernel/kunit.rs
@@ -130,9 +130,9 @@  unsafe impl Sync for UnaryAssert {}
             unsafe {
                 $crate::bindings::__kunit_do_failed_assertion(
                     kunit_test,
-                    core::ptr::addr_of!(LOCATION.0),
+                    &raw const LOCATION.0,
                     $crate::bindings::kunit_assert_type_KUNIT_ASSERTION,
-                    core::ptr::addr_of!(ASSERTION.0.assert),
+                    &raw const ASSERTION.0.assert,
                     Some($crate::bindings::kunit_unary_assert_format),
                     core::ptr::null(),
                 );
@@ -261,7 +261,7 @@  macro_rules! kunit_unsafe_test_suite {
                     // (as documented) must be valid for the lifetime of
                     // the suite (i.e., static).
                     test_cases: unsafe {
-                        ::core::ptr::addr_of_mut!($test_cases)
+                        (&raw mut $test_cases)
                             .cast::<::kernel::bindings::kunit_case>()
                     },
                     suite_init: None,
@@ -283,7 +283,7 @@  macro_rules! kunit_unsafe_test_suite {
             #[cfg_attr(not(target_os = "macos"), link_section = ".kunit_test_suites")]
             static mut KUNIT_TEST_SUITE_ENTRY: *const ::kernel::bindings::kunit_suite =
                 // SAFETY: `KUNIT_TEST_SUITE` is static.
-                unsafe { ::core::ptr::addr_of_mut!(KUNIT_TEST_SUITE) };
+                unsafe { &raw mut KUNIT_TEST_SUITE };
         };
     };
 }