Re: [PATCH v3 04/15] rust: pin-init: internal: add utility API for syn error handling

From: Gary Guo

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


On Wed Jan 14, 2026 at 6:18 PM GMT, Benno Lossin wrote:
> The API is similar to diagnostics handling in rustc and uses a
> `ErrorGuaranteed` value to signify that an error has been emitted. It
> supports both fatal errors (which abort the macro expansion immediately
> by returning `Err(ErrorGuaranteed)`) and non-fatal ones at at generation
> time. These errors are appended to the token stream after generation has
> finished normally. This allows giving good errors while still expanding
> most of the code as expected to avoid the user encountering additional
> errors (for example missing definitions).
>
> Suggested-by: Gary Guo <gary@xxxxxxxxxxx>
> Tested-by: Andreas Hindborg <a.hindborg@xxxxxxxxxx>
> Signed-off-by: Benno Lossin <lossin@xxxxxxxxxx>

Reviewed-by: Gary Guo <gary@xxxxxxxxxxx>

> ---
> Changes in v3: switch to Gary's suggestion
> Changes in v2: added this patch
> ---
> rust/pin-init/internal/src/diagnostics.rs | 32 +++++++++++++++++++++++
> rust/pin-init/internal/src/lib.rs | 1 +
> 2 files changed, 33 insertions(+)
> create mode 100644 rust/pin-init/internal/src/diagnostics.rs