Replies: 1 comment 1 reply
-
|
I prefer macros since it looks more natural for a Rust developer. However, I feel the sequential calls of macros are not united, in which case I think it's better to group them into a block just like Option A. e.g. It can be: And the inner diagnostics can be represented in any order. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Diagnostic API
We're evaluating two approaches for emitting compile-time diagnostics (errors, warnings, notes) from
#[zyn::element]functions.Option A: Template directives (
@throw,@warn,@note,@help)Diagnostics live inside
zyn!templates as@-directives:@throwhalts expansion immediately@noteand@helpnest inside@throw/@warnOption B: Inline macros (
error!,warn!,note!,help!,bail!)Diagnostics are plain Rust macro calls in the element body:
bail!()returns early only if errors accumulatedformat!-style args:error!("field \{}` missing", name)`error!("msg"; span = ident.span())Side-by-side: multiple errors
Option A:
Option B:
Key difference: Option A halts on the first
@throw. Option B accumulates all errors and reports them together withbail!().Feel free to comment with additional thoughts!
2 votes ·
Beta Was this translation helpful? Give feedback.
All reactions