From: "Benno Lossin" <lossin@kernel.org>
To: "Boqun Feng" <boqun.feng@gmail.com>,
"Danilo Krummrich" <dakr@kernel.org>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@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>,
"Fiona Behrens" <me@kloenk.dev>, "Alban Kurti" <kurti@invicto.ai>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Krzysztof Wilczy´nski" <kwilczynski@kernel.org>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rust: pin-init: add references to previously initialized fields
Date: Wed, 10 Sep 2025 12:12:23 +0200 [thread overview]
Message-ID: <DCP1G8B2LF4X.3R6HTYHUX3YAR@kernel.org> (raw)
In-Reply-To: <aL8wnJcro6uXiD74@tardis-2.local>
On Mon Sep 8, 2025 at 9:38 PM CEST, Boqun Feng wrote:
> On Mon, Sep 08, 2025 at 10:57:36AM +0200, Danilo Krummrich wrote:
>> On Mon Sep 8, 2025 at 10:27 AM CEST, Benno Lossin wrote:
>> > On Mon Sep 8, 2025 at 4:08 AM CEST, Boqun Feng wrote:
>> >> On Mon, Sep 08, 2025 at 01:33:26AM +0200, Danilo Krummrich wrote:
>> >>> On Mon Sep 8, 2025 at 12:51 AM CEST, Benno Lossin wrote:
>> >>> > I actually came up with a third option that looks best IMO:
>> >>> >
>> >>> > init!(MyStruct {
>> >>> > x: 42,
>> >>> > #[with_binding]
>> >>> > y: 24,
>> >>> > z: *y,
>> >>> > })
>> >>> >
>> >>> > The `#[with_binding]` attribute makes the macro generate a variable `y`.
>> >>> > `x` & `z` don't give access to their value. (we of course should come up
>> >>> > with a better name).
>> >>> >
>> >>> > Any thoughts?
>> >>>
>> >>> It may be a bit verbose is some cases, but it makes things pretty obvious, so
>> >>> LGTM.
>> >>>
>> >>> How about just #[bind] or #[access]?
>> >
>> > I like `#[bind]`.
>> >
>> >> #[shadow] or #[maybe_rebind] ? Or #[pin_ref], the last one is clear
>> >> about the purpose.
>> >
>> > Hmm in `init!` it's never pinned.
>>
>> I thought about #[shadow] as well, but it is not really accurate I think, as we
>> might not shadow anything. #[maybe_rebind] sounds a bit like it conditionally
>> rebinds, as in "it may not do anything", but it always binds.
>>
>> So, I think it should one clear instruction, i.e. #[bind], #[access], #[ref],
>> #[use], #[let], etc.
>
> In that sense I think `#[let]` is best? Because it indicates this field
> initialization works as a `let`-statement (in term of creating a new
> binding), of course I don't have strong ojections against other options.
Ultimately I decided to go with `#[bind]`, since I felt like `#[let]`
might be confused with just having a let statement (ie replacing the
assignment with a let binding).
`#[bind]` also might be confused with some device binding I guess, but
we can rename it's too bad.
---
Cheers,
Benno
next prev parent reply other threads:[~2025-09-10 10:12 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-05 14:00 [PATCH] rust: pin-init: add references to previously initialized fields Benno Lossin
2025-09-05 17:18 ` Benno Lossin
2025-09-05 17:44 ` Boqun Feng
2025-09-06 10:52 ` Danilo Krummrich
2025-09-07 1:57 ` Boqun Feng
2025-09-07 2:07 ` Boqun Feng
2025-09-07 8:41 ` Benno Lossin
2025-09-07 17:29 ` Danilo Krummrich
2025-09-07 21:06 ` Benno Lossin
2025-09-07 21:39 ` Danilo Krummrich
2025-09-07 22:51 ` Benno Lossin
2025-09-07 23:33 ` Danilo Krummrich
2025-09-08 2:08 ` Boqun Feng
2025-09-08 8:27 ` Benno Lossin
2025-09-08 8:57 ` Danilo Krummrich
2025-09-08 19:38 ` Boqun Feng
2025-09-08 20:31 ` Danilo Krummrich
2025-09-10 10:12 ` Benno Lossin [this message]
2025-09-05 17:21 ` Boqun Feng
2025-09-05 18:38 ` Danilo Krummrich
2025-09-06 14:23 ` kernel test robot
2025-09-11 21:35 ` 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=DCP1G8B2LF4X.3R6HTYHUX3YAR@kernel.org \
--to=lossin@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=bhelgaas@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@kernel.org \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=kurti@invicto.ai \
--cc=kwilczynski@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=me@kloenk.dev \
--cc=ojeda@kernel.org \
--cc=rafael@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).