Re: [PATCH 06/12] rust: pin-init: rewrite `#[pin_data]` using `syn`

From: Benno Lossin

Date: Fri Jan 09 2026 - 11:39:13 EST


On Fri Jan 9, 2026 at 1:47 PM CET, Gary Guo wrote:
> On Thu Jan 8, 2026 at 1:50 PM GMT, Benno Lossin wrote:
>> +impl Parse for Args {
>> + fn parse(input: syn::parse::ParseStream) -> Result<Self> {
>> + let lh = input.lookahead1();
>> + if lh.peek(End) {
>> + input.parse().map(Self::Nothing)
>
> How about make this `impl Parse for Option<Args>` and remove the nothing
> variant? It looks a bit weird.

`Option` is not fundamental, so I can't change the impl. Parse doesn't
have a blanket impl on `Option`. Maybe I'm not fully understanding the
change you're proposing.

>> +fn strip_pin_annotations(struct_: &mut syn::ItemStruct) {
>> + for field in &mut struct_.fields {
>> + field.attrs.retain(|a| !a.path().is_ident("pin"));
>> + }
>> +}
>
> Multiple places have similar things for stripping annotations and checking if
> structurally pinned. Would it make sense to do this at the very beginning, and
> build a `HashSet` of structurally pinned fields, and use that as canonical
> source for all generate_ functions?

There is https://github.com/Rust-for-Linux/pin-init/pull/94, and I don't
want to take away their work. I'll contact them and see if we can fold
it into this commit/series.

Cheers,
Benno