Re: [PATCH v5 17/17] rust: clippy: disallow `addr_of[_mut]!` macros

From: Andreas Hindborg
Date: Thu Mar 20 2025 - 03:35:37 EST


"Antonio Hickey" <contact@xxxxxxxxxxxxxxxxx> writes:

> With the `raw_ref_op` feature enabled we no longer want to
> allow use of the `addr_of!` and `addr_of_mut!` macros.
>
> We instead want to use `&raw const` and `&raw mut` to get raw
> pointers to a place.
>
> Note that this lint isn't currently reliable, but we enable
> it nevertheless because:
> 1. Document that one shouldn't use the `addr_of[_mut]!` macros.
> 2. When the lint becomes useful we will already have it enabled.
>
> Suggested-by: Benno Lossin <benno.lossin@xxxxxxxxx>
> Link: https://github.com/Rust-for-Linux/linux/issues/1148
> Link: https://github.com/rust-lang/rust-clippy/issues/11431
> Signed-off-by: Antonio Hickey <contact@xxxxxxxxxxxxxxxxx>


Reviewed-by: Andreas Hindborg <a.hindborg@xxxxxxxxxx>


Best regards,
Andreas Hindborg