Skip to content

Conversation

@schneems
Copy link

@schneems schneems commented Apr 1, 2025

We should encourage macro authors to emit as many errors as possible at once. This functionality is already present in syn::Error, but it was not immediately clear. I wanted to add some documentation that could have helped me better use the syn::Error::combine functionality.

For some more background https://www.schneems.com/2025/03/26/a-daft-procmacro-trick-how-to-emit-partialcode-errors/.

This commit adds two examples, one shows accumulating "maybe errors" with the aid of VecDeque, and the second shows iterating over the result of combined errors and calls out that this is helpful for unit testing.

We should encourage macro authors to emit as many errors as possible at once. This functionality is already present in syn::Error, but it was not immediately clear. I wanted to add some documentation that could have helped me better use the syn::Error::combine functionality. 

For some more background https://www.schneems.com/2025/03/26/a-daft-procmacro-trick-how-to-emit-partialcode-errors/.

This commit adds two examples, one shows accumulating "maybe errors" with the aid of VecDeque, and the second shows iterating over the result of combined errors and calls out that this is helpful for unit testing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant