[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAH5fLghfeWZ1FYdgQKQ7aBftHEGgXPYZ9WTWueTSZxxtaaRB1A@mail.gmail.com>
Date: Wed, 10 Sep 2025 12:54:59 +0200
From: Alice Ryhl <aliceryhl@...gle.com>
To: Benno Lossin <lossin@...nel.org>
Cc: 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>,
Andreas Hindborg <a.hindborg@...nel.org>, Trevor Gross <tmgross@...ch.edu>,
Danilo Krummrich <dakr@...nel.org>, Tejun Heo <tj@...nel.org>, Tamir Duberstein <tamird@...il.com>,
Dirk Behme <dirk.behme@...il.com>, Alban Kurti <kurti@...icto.ai>, Fiona Behrens <me@...enk.dev>,
rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] rust: pin-init: add pin projections to `#[pin_data]`
On Wed, Sep 10, 2025 at 12:38 PM Benno Lossin <lossin@...nel.org> wrote:
>
> On Wed Sep 10, 2025 at 12:23 PM CEST, Alice Ryhl wrote:
> > On Fri, Sep 5, 2025 at 7:12 PM Benno Lossin <lossin@...nel.org> wrote:
> >> + (make_pin_projections:
> >> + @vis($vis:vis),
> >> + @name($name:ident),
> >> + @impl_generics($($impl_generics:tt)*),
> >> + @ty_generics($($ty_generics:tt)*),
> >> + @decl_generics($($decl_generics:tt)*),
> >> + @where($($whr:tt)*),
> >> + @pinned($($(#[$($p_attr:tt)*])* $pvis:vis $p_field:ident : $p_type:ty),* $(,)?),
> >> + @not_pinned($($(#[$($attr:tt)*])* $fvis:vis $field:ident : $type:ty),* $(,)?),
> >> + ) => {
> >> + $crate::macros::paste! {
> >> + #[doc(hidden)]
> >> + $vis struct [< $name Projection >] <'__pin, $($decl_generics)*> {
> >
> > I'm not sure we want $vis here. That's the visibility of the original
> > struct, but I don't think we want it to be pub just because the struct
> > is.
>
> Why shouldn't it be pub if the original is pub? I don't really
> understand the concern, since the fields themselves will still have the
> correct visibility. Additionally, there is the `___pin_phantom_data`
> field that's always private, so you cannot construct this outside of the
> module.
I mean, for instance, it's going to mean that every single struct that
wraps Opaque in a private field will get a useless pub function called
project that will appear in html docs.
Pin-project limits the visibility to pub(crate) when the struct is pub.
Alice
Powered by blists - more mailing lists