Re: [PATCH v3 09/15] rust: pin-init: rewrite the initializer macros using `syn`

From: Gary Guo

Date: Wed Jan 14 2026 - 13:51:49 EST


On Wed Jan 14, 2026 at 6:18 PM GMT, Benno Lossin wrote:
> Rewrite the initializer macros `[pin_]init!` using `syn`. No functional
> changes intended aside from improved error messages on syntactic and
> semantical errors. For example if one forgets to use `<-` with an
> initializer (and instead uses `:`):
>
> <snip>
>
> Importantly, this error gives much more accurate span locations,
> pointing to the offending field, rather than the entire macro
> invocation.
>
> Tested-by: Andreas Hindborg <a.hindborg@xxxxxxxxxx>
> Signed-off-by: Benno Lossin <lossin@xxxxxxxxxx>

Reviewed-by: Gary Guo <gary@xxxxxxxxxxx>

> ---
> Changes in v3:
> * use DiagCtxt error handling
> Changes in v2:
> * fix clippy error
> * add missing SPDX-License-Identifier
> * improve error handling
> * improve default error evaluation
> * added missing comment from pre-rewrite code
> ---
> rust/pin-init/internal/src/init.rs | 445 ++++++++++++++
> rust/pin-init/internal/src/lib.rs | 13 +
> rust/pin-init/src/lib.rs | 56 +-
> rust/pin-init/src/macros.rs | 951 -----------------------------
> 4 files changed, 460 insertions(+), 1005 deletions(-)
> create mode 100644 rust/pin-init/internal/src/init.rs
> delete mode 100644 rust/pin-init/src/macros.rs