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(-)
linaro-mm-sig@lists.linaro.org