[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DFKDCGI4Z6U6.2DSMGUP222WJ9@garyguo.net>
Date: Fri, 09 Jan 2026 21:16:16 +0000
From: "Gary Guo" <gary@...yguo.net>
To: "Benno Lossin" <lossin@...nel.org>, "Gary Guo" <gary@...yguo.net>,
"Miguel Ojeda" <ojeda@...nel.org>, "Boqun Feng" <boqun.feng@...il.com>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>, "Andreas
Hindborg" <a.hindborg@...nel.org>, "Alice Ryhl" <aliceryhl@...gle.com>,
"Trevor Gross" <tmgross@...ch.edu>, "Danilo Krummrich" <dakr@...nel.org>
Cc: <rust-for-linux@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 11/12] rust: pin-init: internal: init: add support for
attributes on initializer fields
On Fri Jan 9, 2026 at 6:02 PM GMT, Benno Lossin wrote:
> On Fri Jan 9, 2026 at 2:55 PM CET, Gary Guo wrote:
>> On Thu Jan 8, 2026 at 1:50 PM GMT, Benno Lossin wrote:
>>> - if let Some(ident) = field.ident() {
>>> + if let Some(ident) = kind.ident() {
>>> // `mixed_site` ensures that the guard is not accessible to the user-controlled code.
>>> let guard = format_ident!("__{ident}_guard", span = Span::mixed_site());
>>> - guards.push(guard.clone());
>>> res.extend(quote! {
>>> + #(#attrs)*
>>> // Create the drop guard:
>>> //
>>> // We rely on macro hygiene to make it impossible for users to access this local
>>> @@ -316,13 +332,18 @@ fn init_fields(
>>> )
>>> };
>>> });
>>> + guards.push(guard);
>>> + guard_attrs.push(attrs);
>>
>> I think guard_attrs should just get the cfg ones, not including lint levels.
>> Otherwise, `#[expect]` would be broken?
>
> Oh yeah that is probably right. I do not yet have extensive attribute
> tests due to lack of time.
>
> Do you also think that only cfg ones should be included in the
> `#(#attrs)*` in the `quote!` above?
I think the full attribute list should get applied when surrounding the
user-provided expression. Everything else should just get the cfg.
Best,
Gary
Powered by blists - more mailing lists