lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <DCP1G8B2LF4X.3R6HTYHUX3YAR@kernel.org>
Date: Wed, 10 Sep 2025 12:12:23 +0200
From: "Benno Lossin" <lossin@...nel.org>
To: "Boqun Feng" <boqun.feng@...il.com>, "Danilo Krummrich"
 <dakr@...nel.org>
Cc: "Miguel Ojeda" <ojeda@...nel.org>, "Alex Gaynor"
 <alex.gaynor@...il.com>, "Gary Guo" <gary@...yguo.net>,
 Björn Roy Baron <bjorn3_gh@...tonmail.com>, "Andreas
 Hindborg" <a.hindborg@...nel.org>, "Alice Ryhl" <aliceryhl@...gle.com>,
 "Trevor Gross" <tmgross@...ch.edu>, "Fiona Behrens" <me@...enk.dev>, "Alban
 Kurti" <kurti@...icto.ai>, "Greg Kroah-Hartman"
 <gregkh@...uxfoundation.org>, "Rafael J. Wysocki" <rafael@...nel.org>,
 "Bjorn Helgaas" <bhelgaas@...gle.com>,
 Krzysztof Wilczy´nski <kwilczynski@...nel.org>,
 <rust-for-linux@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] rust: pin-init: add references to previously
 initialized fields

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ