-
-
Notifications
You must be signed in to change notification settings - Fork 721
fix(ast_macros): do not panic in macro #13102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
CodSpeed Instrumentation Performance ReportMerging #13102 will not alter performanceComparing Summary
Footnotes |
e582c0a to
c63c944
Compare
a9002da to
abd344c
Compare
abd344c to
304011c
Compare
304011c to
edd0a0e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves error handling in the #[ast] macro to provide better developer experience when AST structs are modified. Previously, the macro would panic with cryptic errors when struct fields didn't match the generated metadata, requiring IDE restarts. Now it generates helpful compile errors that guide users to run the codegen.
- Replaced panic behavior with graceful error handling using
compile_error!macro - Added better error messages directing users to run
just astfor codegen - Improved robustness of the
assert_generated_derivesfunction by handling parsing failures gracefully
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Merge activity
|
edd0a0e to
3c30069
Compare
Previously if you edited an AST struct, adding or removing fields, `#[ast]` macro would panic because the fields of the struct don't match what it's expecting from the `STRUCTS` metadata which is generated by `oxc_ast_tools`. It would cover the whole struct with red squiggles, with a cryptic error message. This was really annoying. Instead, make the macro output a `compile_error!` macro invocation. This makes IDE and `cargo build` show an error saying that you need to run `just ast` to re-run the codegen. Also, because the macro doesn't crash any more, you don't have to re-start Rust Analyser once you've fixed the problem. This is less annoying for humans, and also the more helpful error message will hopefully point AI in the right direction.
3c30069 to
d676e04
Compare

Previously if you edited an AST struct, adding or removing fields,
#[ast]macro would panic because the fields of the struct don't match what it's expecting from theSTRUCTSmetadata which is generated byoxc_ast_tools.It would cover the whole struct with red squiggles, with a cryptic error message. This was really annoying.
Instead, make the macro output a
compile_error!macro invocation. This makes IDE andcargo buildshow an error saying that you need to runjust astto re-run the codegen. Also, because the macro doesn't crash any more, you don't have to re-start Rust Analyser once you've fixed the problem.This is less annoying for humans, and also the more helpful error message will hopefully point AI in the right direction.