From: "Gary Guo" <gary@garyguo.net>
To: "Alice Ryhl" <aliceryhl@google.com>,
"Danilo Krummrich" <dakr@kernel.org>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>
Cc: "Dave Ertman" <david.m.ertman@intel.com>,
"Ira Weiny" <iweiny@kernel.org>,
"Leon Romanovsky" <leon@kernel.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Trevor Gross" <tmgross@umich.edu>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Tamir Duberstein" <tamird@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Onur Özkan" <work@onurozkan.dev>,
"Igor Korotin" <igor.korotin@linux.dev>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
"Sumit Semwal" <sumit.semwal@linaro.org>,
"Christian König" <christian.koenig@amd.com>,
driver-core@lists.linux.dev, rust-for-linux@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,
linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org,
linaro-mm-sig@lists.linaro.org
Subject: Re: [PATCH] rust: device_id: rename IdTable::as_ptr to as_raw_id_table()
Date: Thu, 02 Jul 2026 14:48:24 +0100 [thread overview]
Message-ID: <DJO4SC0M6BCM.B7RP36WUWCM9@garyguo.net> (raw)
In-Reply-To: <20260702-idtable-rename-asptr-v1-1-e0927273c71a@google.com>
On Thu Jul 2, 2026 at 1:30 PM BST, Alice Ryhl wrote:
> The current name of `as_ptr` is very generic, and if you attempt to
> invoke `foo.as_ptr()` on a type for which this method is missing, then
> an error along these lines will be printed:
>
> error[E0599]: no method named `as_ptr` found for reference `&DmaBuf` in the current scope
> --> linux/rust/kernel/dma_buf/buf.rs:54:38
> |
> 54 | ptr::eq(self.as_ptr(), other.as_ptr())
> | ^^^^^^ method not found in `&DmaBuf`
> |
> = help: items from traits can only be used if the trait is implemented and in scope
> note: `device_id::IdTable` defines an item `as_ptr`, perhaps you need to implement it
> --> linux/rust/kernel/device_id.rs:165:1
> |
> 165 | pub trait IdTable<T: RawDeviceId, U> {
> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> Suggesting the IdTable trait when an as_ptr() method is missing is not
> useful. Renaming it to `as_raw_id_table` makes the method name unique to
> this trait and avoids these bad suggestions.
I think the name is fine. Functions of this sort is named `as_ptr()` and I don't
see why it should differ just because it's on traits.
I'd rather say this is a Rust deficiency. Perhaps there needs to be a
improvement of `#[diagnostic::do_not_recommend]` so it can be sticked to methods
or traits as well.
Best,
Gary
>
> Assisted-by: Antigravity:Gemini
> Signed-off-by: Alice Ryhl <aliceryhl@google.com>
> ---
> rust/kernel/auxiliary.rs | 2 +-
> rust/kernel/device_id.rs | 4 ++--
> rust/kernel/driver.rs | 8 +++++---
> rust/kernel/i2c.rs | 8 ++++----
> rust/kernel/pci.rs | 2 +-
> rust/kernel/platform.rs | 4 ++--
> rust/kernel/usb.rs | 2 +-
> 7 files changed, 16 insertions(+), 14 deletions(-)
next prev parent reply other threads:[~2026-07-02 13:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-02 12:30 [PATCH] rust: device_id: rename IdTable::as_ptr to as_raw_id_table() Alice Ryhl
2026-07-02 13:48 ` Gary Guo [this message]
2026-07-02 13:59 ` Alice Ryhl
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=DJO4SC0M6BCM.B7RP36WUWCM9@garyguo.net \
--to=gary@garyguo.net \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=bhelgaas@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=christian.koenig@amd.com \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=david.m.ertman@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=igor.korotin@linux.dev \
--cc=iweiny@kernel.org \
--cc=kwilczynski@kernel.org \
--cc=leon@kernel.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=rafael@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=sumit.semwal@linaro.org \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.dev \
/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