From: Benno Lossin <benno.lossin@proton.me>
To: "Antonio Hickey" <contact@antoniohickey.com>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>
Cc: Benno Lossin <y86-dev@protonmail.com>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] rust: clippy: disable `addr_of!` and `addr_of_mut` macros
Date: Thu, 13 Mar 2025 12:16:32 +0000 [thread overview]
Message-ID: <D8F4QM62027Y.1EP8OGGCCSAB4@proton.me> (raw)
On Thu Mar 13, 2025 at 6:33 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.
>
> 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>
This patch needs to be done after changing all occurrences of
`addr_of[_mut]!`, ie the next one (otherwise it would warn about them).
I also noticed that this feature sadly doesn't work very well, see
https://rust-for-linux.zulipchat.com/#narrow/channel/291565-Help/topic/.2Eclippy.2Etoml.20has.20no.20effect
and
https://github.com/rust-lang/rust-clippy/issues/11431
---
Cheers,
Benno
> ---
> .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!`" },
> ]
next reply other threads:[~2025-03-13 12:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-13 12:16 Benno Lossin [this message]
[not found] <20250313053340.405979-1-contact@antoniohickey.com>
2025-03-13 5:33 ` [PATCH 2/3] rust: clippy: disable `addr_of!` and `addr_of_mut` macros Antonio Hickey
2025-03-14 5:54 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=D8F4QM62027Y.1EP8OGGCCSAB4@proton.me \
--to=benno.lossin@proton.me \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=contact@antoniohickey.com \
--cc=dakr@kernel.org \
--cc=gary@garyguo.net \
--cc=linux-kernel@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
--cc=y86-dev@protonmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).