From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D747325A34B; Wed, 10 Sep 2025 10:12:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757499148; cv=none; b=bBQUDz/casKNP8NjBLupYqKGLqpZe0aH2gDipWfQbYtQiWQQFv/E7kGC7hM57qtN7wEHyIpovwHmm8XmUNrlqxu0S6CKGjU+mUyiWR+GTyA0rHT/FUJpcrBpaBPHdQq5FH+Q/VdDu6srJ80ut0vYaXcmZMPp25NGkqK4r7zEKSA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757499148; c=relaxed/simple; bh=bYXhpBox2lBn11Q9QPO3VJPiL3p6yhug4eB2dcXMO+g=; h=Mime-Version:Content-Type:Date:Message-Id:To:Cc:Subject:From: References:In-Reply-To; b=XLIjkOsvJgNZoSYMV5l8WRDOYIYOPr6L8cafXbnJC6DlU/DhZxf3lPN3aLvXQg+7nsgXF+DdICZhYvBIeYIdBYjsFz1WdvsdgCpHhruNUtEehHp3pW62HsUfueoGK1PTJkadPqmEZbAmw9Zrlq/HHPCjD2b3KlTn02KQDzEkEtg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VnA73z3D; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VnA73z3D" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 426C1C4CEF0; Wed, 10 Sep 2025 10:12:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757499148; bh=bYXhpBox2lBn11Q9QPO3VJPiL3p6yhug4eB2dcXMO+g=; h=Date:To:Cc:Subject:From:References:In-Reply-To:From; b=VnA73z3D8HGvjHrGBGTrr2EkW7eMKJC+or4GVSL5gp79sdzZM5IgmKmlBMOROgMNU yz85+U4FBS45CKXaBCgT53p/sw7KXybyaEpXht6FWfF6UhrMRubJBNbxcIie4ykH89 KwrPi5YaCR0L1oTabyR/QFxoXploXtErb3sEUMPepDfnqrcmRdm9hTobk3J64D8BpK AeGZzgb8dtJfIrF9Jv9KJ/voa8hJjWtH03vhBbhYc3iJxmIlhyNYKI5EJPK9vsfM1Q aIUiTPbKVs4OhNsSdACqBC+qFVtC5NDx4vFvUv9jwKNohNXphoKUjK5jvfzkXrubIP eoDmk7CBZct8A== Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Wed, 10 Sep 2025 12:12:23 +0200 Message-Id: To: "Boqun Feng" , "Danilo Krummrich" Cc: "Miguel Ojeda" , "Alex Gaynor" , "Gary Guo" , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , "Andreas Hindborg" , "Alice Ryhl" , "Trevor Gross" , "Fiona Behrens" , "Alban Kurti" , "Greg Kroah-Hartman" , "Rafael J. Wysocki" , "Bjorn Helgaas" , =?utf-8?q?Krzysztof_Wilczy=C2=B4nski?= , , Subject: Re: [PATCH] rust: pin-init: add references to previously initialized fields From: "Benno Lossin" X-Mailer: aerc 0.20.1 References: In-Reply-To: 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 variabl= e `y`. >> >>> > `x` & `z` don't give access to their value. (we of course should c= ome up >> >>> > with a better name). >> >>> > >> >>> > Any thoughts? >> >>>=20 >> >>> It may be a bit verbose is some cases, but it makes things pretty ob= vious, so >> >>> LGTM. >> >>>=20 >> >>> 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. >>=20 >> 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 conditio= nally >> rebinds, as in "it may not do anything", but it always binds. >>=20 >> 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