From: Benno Lossin <benno.lossin@proton.me>
To: "Christian Schrefl" <chrisi.schrefl@gmail.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>,
"Fiona Behrens" <me@kloenk.dev>
Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/8] rust: pin-init: Implement `Wrapper` for `UnsafePinned` behind feature flag.
Date: Tue, 22 Apr 2025 11:21:25 +0000 [thread overview]
Message-ID: <D9D4M8XF14X9.1YUVFH9EW0IMX@proton.me> (raw)
In-Reply-To: <4df4e3a0-9caa-4253-bf65-66c238bf0291@gmail.com>
On Tue Apr 22, 2025 at 11:42 AM CEST, Christian Schrefl wrote:
> On 22.04.25 12:18 AM, Benno Lossin wrote:
>> @@ -1557,3 +1561,11 @@ fn pin_init<E>(value_init: impl PinInit<T, E>) -> impl PinInit<Self, E> {
>> unsafe { cast_pin_init(value_init) }
>> }
>> }
>> +
>> +#[cfg(all(feature = "unsafe-pinned", CONFIG_RUSTC_HAS_UNSAFE_PINNED))]
>> +impl<T> Wrapper<T> for core::pin::UnsafePinned<T> {
>> + fn pin_init<E>(init: impl PinInit<T, E>) -> impl PinInit<Self, E> {
>> + // SAFETY: `UnsafePinned<T>` has a compatible layout to `T`.
>> + unsafe { cast_pin_init(init) }
>> + }
>> +}
>
> I've realized that for us to use `UnsafePinned` in `Opaque` internally
> we need to have a `T: ?Sized` for this implementation. `cast_pin_init`
> won't work for that since we can't cast pointers between different DSTs.
> We could add something similar that uses a closure to convert a
> `*mut T` to `*mut U`.
I don't follow, which types do you need to wrap in `Opaque` that are not
sized?
Since `Opaque` uses `MaybeUninit` under the hood, it cannot support
`!Sized` types anyways, so I'm a bit confused.
---
Cheers,
Benno
next prev parent reply other threads:[~2025-04-22 11:21 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-21 22:17 [PATCH 0/8] pin-init sync for v6.16 Benno Lossin
2025-04-21 22:17 ` [PATCH 1/8] rust: pin-init: add `cast_[pin_]init` functions to change the initialized type Benno Lossin
2025-04-22 6:56 ` Christian Schrefl
2025-04-21 22:17 ` [PATCH 2/8] rust: pin-init: Add the `Wrapper` trait Benno Lossin
2025-04-22 4:44 ` Boqun Feng
2025-04-21 22:18 ` [PATCH 3/8] rust: pin-init: Implement `Wrapper` for `UnsafePinned` behind feature flag Benno Lossin
2025-04-22 9:42 ` Christian Schrefl
2025-04-22 11:21 ` Benno Lossin [this message]
2025-04-22 14:17 ` Christian Schrefl
2025-04-21 22:18 ` [PATCH 4/8] rust: pin-init: Update Changelog and Readme Benno Lossin
2025-04-21 22:18 ` [PATCH 5/8] rust: pin-init: Update the structural pinning link in readme Benno Lossin
2025-04-21 22:18 ` [PATCH 6/8] rust: pin-init: allow `pub` fields in `derive(Zeroable)` Benno Lossin
2025-04-22 4:55 ` Boqun Feng
2025-04-22 8:30 ` Benno Lossin
2025-04-22 14:14 ` Boqun Feng
2025-04-22 14:45 ` Benno Lossin
2025-04-22 21:11 ` Boqun Feng
2025-04-22 21:56 ` Benno Lossin
2025-04-21 22:18 ` [PATCH 7/8] rust: pin-init: allow `Zeroable` derive macro to also be applied to unions Benno Lossin
2025-04-21 22:18 ` [PATCH 8/8] rust: pin-init: add `MaybeZeroable` derive macro Benno Lossin
2025-04-22 4:54 ` Boqun Feng
2025-04-22 7:56 ` Benno Lossin
2025-05-01 16:38 ` [PATCH 0/8] pin-init sync for v6.16 Benno Lossin
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=D9D4M8XF14X9.1YUVFH9EW0IMX@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=chrisi.schrefl@gmail.com \
--cc=dakr@kernel.org \
--cc=gary@garyguo.net \
--cc=linux-kernel@vger.kernel.org \
--cc=me@kloenk.dev \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
/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).