mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: [PATCH v3 3/3] rust: clippy: disable `addr_of!` and `addr_of_mut` macros
@ 2025-03-15  9:59 Benno Lossin
  0 siblings, 0 replies; 2+ messages in thread
From: Benno Lossin @ 2025-03-15  9:59 UTC (permalink / raw)
  To: Antonio Hickey, Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich
  Cc: Benno Lossin, rust-for-linux, linux-kernel

On Sat Mar 15, 2025 at 12:41 AM CET, Antonio Hickey wrote:
> With the `raw_ref_op` feature enabled we no longer want to
> allow use of `addr_of!` and `addr_of_mut!` macros.
>
> We instead want to use `&raw` and `&raw mut` to get raw
> pointers to a place.

To what line length are you wrapping this commit message? I usually do
72 (and I think checkpatch also checks for that?).

Also it would be useful if you could link to
https://github.com/rust-lang/rust-clippy/issues/11431
and note that the lint isn't currently reliable, but we enable it
nevertheless to 1) document that one shouldn't use the `addr_of!` macros
and 2) when the lint becomes useful, we already have it enabled.

> Suggested-by: Benno Lossin <y86-dev@protonmail.com>

Please change my email to <benno.lossin@proton.me>.

> Link: https://github.com/Rust-for-Linux/linux/issues/1148
> Signed-off-by: Antonio Hickey <contact@antoniohickey.com>
> ---
>  .clippy.toml | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/.clippy.toml b/.clippy.toml
> index 815c94732ed7..95c73959f039 100644
> --- a/.clippy.toml
> +++ b/.clippy.toml
> @@ -8,4 +8,8 @@ disallowed-macros = [
>      # The `clippy::dbg_macro` lint only works with `std::dbg!`, thus we simulate
>      # it here, see: https://github.com/rust-lang/rust-clippy/issues/11303.
>      { path = "kernel::dbg", reason = "the `dbg!` macro is intended as a debugging tool" },
> +    # With `raw_ref_op` feature enabled we no longer want to allow use of `addr_of!`
> +    # and `addr_of_mut!` macros, but instead use `&raw` or `&raw mut`.
> +    { path = "core::ptr::addr_of_mut", reason = "use `&raw mut` instead `addr_of_mut!`" },
> +    { path = "core::ptr::addr_of", reason = "use `&raw` instead `addr_of!`" },

This should be `&raw const`. With this and the above changes done, you
may add:

Reviewed-by: Benno Lossin <benno.lossin@proton.me>

---
Cheers,
Benno


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

* [PATCH v3 3/3] rust: clippy: disable `addr_of!` and `addr_of_mut` macros
       [not found] <20250314234148.599196-1-contact@antoniohickey.com>
@ 2025-03-14 23:41 ` Antonio Hickey
  0 siblings, 0 replies; 2+ messages in thread
From: Antonio Hickey @ 2025-03-14 23:41 UTC (permalink / raw)
  To: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich
  Cc: Antonio Hickey, Benno Lossin, rust-for-linux, linux-kernel

With the `raw_ref_op` feature enabled we no longer want to
allow use of `addr_of!` and `addr_of_mut!` macros.

We instead want to use `&raw` and `&raw mut` to get raw
pointers to a place.

Suggested-by: Benno Lossin <y86-dev@protonmail.com>
Link: https://github.com/Rust-for-Linux/linux/issues/1148
Signed-off-by: Antonio Hickey <contact@antoniohickey.com>
---
 .clippy.toml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/.clippy.toml b/.clippy.toml
index 815c94732ed7..95c73959f039 100644
--- a/.clippy.toml
+++ b/.clippy.toml
@@ -8,4 +8,8 @@ disallowed-macros = [
     # The `clippy::dbg_macro` lint only works with `std::dbg!`, thus we simulate
     # it here, see: https://github.com/rust-lang/rust-clippy/issues/11303.
     { path = "kernel::dbg", reason = "the `dbg!` macro is intended as a debugging tool" },
+    # With `raw_ref_op` feature enabled we no longer want to allow use of `addr_of!`
+    # and `addr_of_mut!` macros, but instead use `&raw` or `&raw mut`.
+    { path = "core::ptr::addr_of_mut", reason = "use `&raw mut` instead `addr_of_mut!`" },
+    { path = "core::ptr::addr_of", reason = "use `&raw` instead `addr_of!`" },
 ]
-- 
2.48.1


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

end of thread, other threads:[~2025-03-15  9:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-15  9:59 [PATCH v3 3/3] rust: clippy: disable `addr_of!` and `addr_of_mut` macros Benno Lossin
     [not found] <20250314234148.599196-1-contact@antoniohickey.com>
2025-03-14 23:41 ` Antonio Hickey

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

all inboxes | Powered by JetHome®