Re: [PATCH 11/12] rust: pin-init: internal: init: add support for attributes on initializer fields
From: Benno Lossin
Date: Fri Jan 09 2026 - 13:03:03 EST
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?
Cheers,
Benno