]> git.ipfire.org Git - thirdparty/linux.git/commit
rust: pin-init: internal: add utility API for syn error handling
authorBenno Lossin <lossin@kernel.org>
Fri, 16 Jan 2026 10:54:19 +0000 (11:54 +0100)
committerBenno Lossin <lossin@kernel.org>
Sat, 17 Jan 2026 09:51:21 +0000 (10:51 +0100)
commit26bd9402389eaebed086755afb03453dcae6617a
tree0d1b89786d5e701eb0167ecef9dabe07e0aef82d
parent514e4ed2c9da9112fcd378b1bd9b9d120edf7ca9
rust: pin-init: internal: add utility API for syn error handling

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 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@garyguo.net>
Tested-by: Andreas Hindborg <a.hindborg@kernel.org>
Reviewed-by: Gary Guo <gary@garyguo.net>
[ remove duplicate word in commit message - Benno ]
Signed-off-by: Benno Lossin <lossin@kernel.org>
rust/pin-init/internal/src/diagnostics.rs [new file with mode: 0644]
rust/pin-init/internal/src/lib.rs