[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <DCP4UN1A8JTR.2F29BUUOZ0MW9@kernel.org>
Date: Wed, 10 Sep 2025 14:52:15 +0200
From: "Benno Lossin" <lossin@...nel.org>
To: "Alice Ryhl" <aliceryhl@...gle.com>
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 2:28 PM CEST, Alice Ryhl wrote:
> On Wed, Sep 10, 2025 at 2:18 PM Benno Lossin <lossin@...nel.org> wrote:
>>
>> On Wed Sep 10, 2025 at 12:54 PM CEST, Alice Ryhl wrote:
>> > 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.
>>
>> It's `#[doc(hidden)]` :)
>>
>> > Pin-project limits the visibility to pub(crate) when the struct is pub.
>>
>> I think I would have to look inside the `vis` to recreate that behavior,
>> so I'd rather do it as a future patch. Thoughts?
>
> You could make the struct and method always pub(crate)?
That doesn't work for module-private structs though?
---
Cheers,
Benno
Powered by blists - more mailing lists