From: Benno Lossin <benno.lossin@proton.me>
To: "Tamir Duberstein" <tamird@gmail.com>,
"Danilo Krummrich" <dakr@kernel.org>,
"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>,
"Matthew Wilcox" <willy@infradead.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"FUJITA Tomonori" <fujita.tomonori@gmail.com>,
"Rob Herring (Arm)" <robh@kernel.org>
Cc: "Maíra Canal" <mcanal@igalia.com>,
"Asahi Lina" <lina@asahilina.net>,
rust-for-linux@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,
"Fiona Behrens" <me@kloenk.dev>
Subject: Re: [PATCH v16 2/4] rust: types: add `ForeignOwnable::PointedTo`
Date: Mon, 17 Feb 2025 01:39:40 +0000 [thread overview]
Message-ID: <96d799a7-ec70-4d3f-951b-52c56b545255@proton.me> (raw)
In-Reply-To: <20250207-rust-xarray-bindings-v16-2-256b0cf936bd@gmail.com>
On 07.02.25 14:58, Tamir Duberstein wrote:
> Allow implementors to specify the foreign pointer type; this exposes
> information about the pointed-to type such as its alignment.
>
> This requires the trait to be `unsafe` since it is now possible for
> implementors to break soundness by returning a misaligned pointer.
>
> Encoding the pointer type in the trait (and avoiding pointer casts)
> allows the compiler to check that implementors return the correct
> pointer type. This is preferable to directly encoding the alignment in
> the trait using a constant as the compiler would be unable to check it.
>
> Reviewed-by: Alice Ryhl <aliceryhl@google.com>
> Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org>
> Reviewed-by: Fiona Behrens <me@kloenk.dev>
> Signed-off-by: Tamir Duberstein <tamird@gmail.com>
> ---
> rust/kernel/alloc/kbox.rs | 38 ++++++++++++++++++++------------------
> rust/kernel/miscdevice.rs | 7 ++++++-
> rust/kernel/pci.rs | 2 ++
> rust/kernel/platform.rs | 2 ++
> rust/kernel/sync/arc.rs | 21 ++++++++++++---------
> rust/kernel/types.rs | 46 +++++++++++++++++++++++++++++++---------------
> 6 files changed, 73 insertions(+), 43 deletions(-)
When compiling this (on top of rust-next), I get the following error:
error[E0308]: mismatched types
--> rust/kernel/miscdevice.rs:300:62
|
300 | let device = unsafe { <T::Ptr as ForeignOwnable>::borrow(private) };
| ---------------------------------- ^^^^^^^ expected `*mut <<T as MiscDevice>::Ptr as ForeignOwnable>::PointedTo`, found `*mut c_void`
| |
| arguments to this function are incorrect
|
= note: expected raw pointer `*mut <<T as MiscDevice>::Ptr as ForeignOwnable>::PointedTo`
found raw pointer `*mut c_void`
= help: consider constraining the associated type `<<T as MiscDevice>::Ptr as ForeignOwnable>::PointedTo` to `c_void` or calling a method that returns `<<T as MiscDevice>::Ptr as ForeignOwnable>::PointedTo`
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
note: associated function defined here
--> rust/kernel/types.rs:98:15
|
98 | unsafe fn borrow<'a>(ptr: *mut Self::PointedTo) -> Self::Borrowed<'a>;
| ^^^^^^
error: aborting due to 1 previous error
Can anyone reproduce?
---
Cheers,
Benno
next prev parent reply other threads:[~2025-02-17 1:39 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-07 13:58 [PATCH v16 0/4] rust: xarray: Add a minimal abstraction for XArray Tamir Duberstein
2025-02-07 13:58 ` [PATCH v16 1/4] rust: remove redundant `as _` casts Tamir Duberstein
2025-02-17 11:06 ` Danilo Krummrich
2025-02-07 13:58 ` [PATCH v16 2/4] rust: types: add `ForeignOwnable::PointedTo` Tamir Duberstein
2025-02-17 1:39 ` Benno Lossin [this message]
2025-02-17 1:58 ` Tamir Duberstein
2025-02-17 12:12 ` Danilo Krummrich
2025-02-17 14:02 ` Tamir Duberstein
2025-02-17 14:15 ` Danilo Krummrich
2025-02-17 14:21 ` Tamir Duberstein
2025-02-17 14:37 ` Danilo Krummrich
2025-02-17 14:47 ` Tamir Duberstein
2025-02-17 14:51 ` Danilo Krummrich
2025-02-17 15:50 ` Tamir Duberstein
2025-02-17 16:35 ` Danilo Krummrich
2025-02-17 17:03 ` Miguel Ojeda
2025-02-17 17:03 ` Miguel Ojeda
2025-02-17 17:03 ` Miguel Ojeda
2025-02-17 17:11 ` Tamir Duberstein
2025-02-17 17:24 ` Miguel Ojeda
2025-02-17 17:36 ` Miguel Ojeda
2025-02-17 17:43 ` Tamir Duberstein
2025-02-17 18:12 ` Miguel Ojeda
2025-02-17 18:24 ` Tamir Duberstein
2025-02-18 8:59 ` Andreas Hindborg
2025-02-07 13:58 ` [PATCH v16 3/4] rust: xarray: Add an abstraction for XArray Tamir Duberstein
2025-02-17 11:35 ` Danilo Krummrich
2025-02-17 13:43 ` Tamir Duberstein
2025-02-17 13:57 ` Danilo Krummrich
2025-02-07 13:58 ` [PATCH v16 4/4] MAINTAINERS: add entry for Rust XArray API Tamir Duberstein
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=96d799a7-ec70-4d3f-951b-52c56b545255@proton.me \
--to=benno.lossin@proton.me \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=bhelgaas@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@kernel.org \
--cc=fujita.tomonori@gmail.com \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=lina@asahilina.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=mcanal@igalia.com \
--cc=me@kloenk.dev \
--cc=ojeda@kernel.org \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@gmail.com \
--cc=tmgross@umich.edu \
--cc=willy@infradead.org \
/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).