Re: [PATCH v2] scripts: generate_rust_analyzer: fix resolution of #[pin_data] macros

From: Jesung Yang

Date: Sat Jan 24 2026 - 00:00:17 EST


On Sat Jan 24, 2026 at 11:14 AM KST, 하승종 wrote:
> 2026년 1월 24일 (토) AM 9:43, Jesung Yang <y.j3ms.n@xxxxxxxxx>님이 작성:
[...]
>> Perhaps I'm missing something, but I wasn't able to reproduce this
>> problem (which I think is expected as the `kernel` crate already depends
>> on `pin_init`) with the following setup:
>>
>> Tree: linux-next (next-20260122) [1]
>> (includes latest changes from `rust-fixes` and `pin-init-next`)
>> Files: samples/rust/rust_*.rs, specifically rust_configfs.rs
>> rust-analyzer: 2024-04-29 (which corresponds to our MSRV), 2026-01-12
>>
>> Could you share your environment details and a minimal reproducible
>> example?
>
> Sure! Here are the details of my environment:
> Tree: rust-fixes (commit a44bfed) [2]
> rust-analyzer: The latest stable release (managed by the Zed IDE
> default channel).
>
> verified the issue with the following modules:
> - samples/rust/rust_configfs.rs
> - drivers/block/rnull/rnull.rs
>
> My reproduction steps were:
> 1. Without the patch: Hovering over structs annotated with #[pin_data]
> (e.g., RustConfigfs, NullBlkModule) provided no information/diagnostics.
> 2. "Go to Definition" on those symbols also failed to locate the definition.
> 3. After applying this patch and restarting the LSP server, both
> actions succeeded.

I've discovered that rust-analyzer fails to resolve
`#[pin_data]`-annotated structs if (and only if) we compile our
proc-macros, which essentially feeds `*.so` files to rust-analyzer. If
we don't compile anything, it resolves those structs correctly (despite
some diagnostic errors, if enabled).

This issue appears to be related to rust-analyzer's proc-macro expansion
logic, but anyway, this simple patch restores the IDE functionality. So,

Reviewed-by: Jesung Yang <y.j3ms.n@xxxxxxxxx>

Thanks!

Best regards,
Jesung