Re: [PATCH v4 02/16] rust: init: refactor to use `&raw [const|mut]`

From: Benno Lossin
Date: Sun Mar 16 2025 - 06:15:22 EST


On Sun Mar 16, 2025 at 7:14 AM CET, Antonio Hickey wrote:
> 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@xxxxxxxxx>
> Link: https://github.com/Rust-for-Linux/linux/issues/1148
> Signed-off-by: Antonio Hickey <contact@xxxxxxxxxxxxxxxxx>
> ---
> rust/kernel/init.rs | 8 ++++----
> rust/kernel/init/macros.rs | 28 ++++++++++++++--------------
> 2 files changed, 18 insertions(+), 18 deletions(-)

When compiling this on Rust 1.78, I get:

error[E0658]: raw address of syntax is experimental
--> drivers/block/rnull.rs:57:9
|
57 | / try_pin_init!(Self {
58 | | _disk <- new_mutex!(disk?, "nullb:disk"),
59 | | })
| |__________^
|
= note: see issue #64490 <https://github.com/rust-lang/rust/issues/64490> for more information
= help: add `#![feature(raw_ref_op)]` to the crate attributes to enable
= note: this compiler was built on 2024-04-29; consider upgrading it if it is out of date
= note: this error originates in the macro `$crate::__init_internal` which comes from the expansion of the macro `try_pin_init` (in Nightly builds, run with -Z macro-backtrace for more info)

So the previous commit also needs to affect doctests.

---
Cheers,
Benno