[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87bjqv3ncr.fsf@kernel.org>
Date: Tue, 10 Jun 2025 12:25:08 +0200
From: Andreas Hindborg <a.hindborg@...nel.org>
To: "Benno Lossin" <lossin@...nel.org>
Cc: "Danilo Krummrich" <dakr@...nel.org>, "Miguel Ojeda"
<ojeda@...nel.org>, "Alex Gaynor" <alex.gaynor@...il.com>, "Boqun Feng"
<boqun.feng@...il.com>, "Gary Guo" <gary@...yguo.net>, Björn Roy Baron
<bjorn3_gh@...tonmail.com>, "Alice Ryhl" <aliceryhl@...gle.com>, "Trevor
Gross" <tmgross@...ch.edu>, "Bjorn Helgaas" <bhelgaas@...gle.com>,
Krzysztof Wilczyński <kwilczynski@...nel.org>, "Greg
Kroah-Hartman"
<gregkh@...uxfoundation.org>, "Rafael J. Wysocki" <rafael@...nel.org>,
"Tamir Duberstein" <tamird@...il.com>, "Viresh Kumar"
<viresh.kumar@...aro.org>, <rust-for-linux@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <linux-pci@...r.kernel.org>,
Maíra
Canal <mcanal@...lia.com>
Subject: Re: [PATCH] rust: types: add FOREIGN_ALIGN to ForeignOwnable
"Benno Lossin" <lossin@...nel.org> writes:
> On Tue Jun 10, 2025 at 11:27 AM CEST, Andreas Hindborg wrote:
>> Hi Benno,
>>
>> "Benno Lossin" <lossin@...nel.org> writes:
>>
>>> The title should probably also mention that it removes `PointedTo`.
>
> Just making sure that you saw this.
>
>>> On Thu Jun 5, 2025 at 9:55 PM CEST, Andreas Hindborg wrote:
>>>> pub unsafe trait ForeignOwnable: Sized {
>>>> - /// Type used when the value is foreign-owned. In practical terms only defines the alignment of
>>>> - /// the pointer.
>>>> - type PointedTo;
>>>> + /// The alignment of pointers returned by `into_foreign`.
>>>> + const FOREIGN_ALIGN: usize;
>>>>
>>>> /// Type used to immutably borrow a value that is currently foreign-owned.
>>>> type Borrowed<'a>;
>>>> @@ -39,18 +35,17 @@ pub unsafe trait ForeignOwnable: Sized {
>>>>
>>>> /// Converts a Rust-owned object to a foreign-owned one.
>>>> ///
>>>> - /// # Guarantees
>>>
>>> Why remove this section? I think we should streamline it, (make it use
>>> bullet points, shorten the sentences etc). We can keep the paragraph you
>>> wrote below as normal docs.
>>
>> Not sure exactly what you are going for here. How is this:
>>
>>
>> Converts a Rust-owned object to a foreign-owned one.
>>
>> The foreign representation is a pointer to void.
>>
>> # Guarantees
>>
>> - Minimum alignment of returned pointer is [`Self::FOREIGN_ALIGN`].
>>
>> There are no other guarantees for this pointer. For example, it might be invalid, dangling
>> or pointing to uninitialized memory. Using it in any way except for [`from_foreign`],
>> [`try_from_foreign`], [`borrow`], or [`borrow_mut`] can result in undefined behavior.
>
> Maybe even move this paragraph above the `Guarantees` section and change
> the beginning of it to "Aside from the guarantees listed below, there
> are no other..."?
Alright.
Best regards,
Andreas Hindborg
Powered by blists - more mailing lists