rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Benno Lossin" <lossin@kernel.org>
To: "Alice Ryhl" <aliceryhl@google.com>
Cc: "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>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Danilo Krummrich" <dakr@kernel.org>, "Tejun Heo" <tj@kernel.org>,
	"Tamir Duberstein" <tamird@gmail.com>,
	"Dirk Behme" <dirk.behme@gmail.com>,
	"Alban Kurti" <kurti@invicto.ai>, "Fiona Behrens" <me@kloenk.dev>,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] rust: pin-init: add pin projections to `#[pin_data]`
Date: Wed, 10 Sep 2025 14:52:15 +0200	[thread overview]
Message-ID: <DCP4UN1A8JTR.2F29BUUOZ0MW9@kernel.org> (raw)
In-Reply-To: <CAH5fLgjZnnPRLn8LpaXrQ4hbqig07+N=7q7b0E+9JL1hnXCOVg@mail.gmail.com>

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@kernel.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@kernel.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@kernel.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

  reply	other threads:[~2025-09-10 12:52 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-05 17:12 [PATCH 1/2] rust: pin-init: rename `project` -> `project_this` in doctest Benno Lossin
2025-09-05 17:12 ` [PATCH 2/2] rust: pin-init: add pin projections to `#[pin_data]` Benno Lossin
2025-09-10 10:23   ` Alice Ryhl
2025-09-10 10:24     ` Alice Ryhl
2025-09-10 10:38       ` Benno Lossin
2025-09-10 10:38     ` Benno Lossin
2025-09-10 10:54       ` Alice Ryhl
2025-09-10 12:18         ` Benno Lossin
2025-09-10 12:28           ` Alice Ryhl
2025-09-10 12:52             ` Benno Lossin [this message]
2025-09-11  3:31           ` Boqun Feng
2025-09-10 22:20   ` Gary Guo
2025-09-11 21:32 ` [PATCH 1/2] rust: pin-init: rename `project` -> `project_this` in doctest 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=DCP4UN1A8JTR.2F29BUUOZ0MW9@kernel.org \
    --to=lossin@kernel.org \
    --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=dakr@kernel.org \
    --cc=dirk.behme@gmail.com \
    --cc=gary@garyguo.net \
    --cc=kurti@invicto.ai \
    --cc=linux-kernel@vger.kernel.org \
    --cc=me@kloenk.dev \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tamird@gmail.com \
    --cc=tj@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).