Replace panics with proper compile errors in jet_push_macros#55
Conversation
Changed Files
|
Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com>
Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com>
Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com>
Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR refactors error handling in the jet_push_macros procedural macro from panic-based failures to proper compile-time errors using syn::Error. The change improves developer experience by providing clear, token-specific error messages instead of cryptic internal compiler errors.
Changes:
- Introduced new
jet_push_macroscrate with proper proc macro error handling using the shim +_innerpattern - Replaced manual PUSH macro definitions in test code with generated versions from the proc macro
- Added comprehensive test coverage including functional tests and compile_fail examples
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/jet_push_macros/Cargo.toml | New proc macro crate configuration with syn, quote, and proc-macro2 dependencies |
| crates/jet_push_macros/src/lib.rs | Core proc macro implementation using syn::Error for all error cases |
| crates/jet_push_macros/tests/macro_tests.rs | Functional tests covering PUSH0-PUSH5 and PUSH32 macro generation |
| crates/jet_push_macros/tests/compile_fail/*.rs | Error case documentation (not_integer, not_range, open_range, invalid_range) |
| crates/jet/tests/test_roms.rs | Integration update replacing manual PUSH macros with generated versions |
| crates/jet/Cargo.toml | Added jet_push_macros as dev dependency |
| Cargo.toml | Added jet_push_macros to workspace members |
| Cargo.lock | Dependency graph updates for new crate |
|
@copilot Merge your suggestion, and you broke the build. You have an unused variable. I don't know if it's supposed to be unused and you just failed to remove it, or if you messed up even worse than that and removed some code that you shouldn't have that should be using it. Either way, you need to fix it. |
Fixed in commit 1c5e099. The unused |
1c5e099 to
262e5e4
Compare
* Initial plan * Add jet_push_macros crate and integrate with test_roms Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * Add allow(unused_macros) and format code Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * Fix Cargo.toml formatting Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> * Replace panics with proper compile errors in proc macro Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tcrypt25519 <212655132+tcrypt25519@users.noreply.github.com>
Plan: Replace panics with proper compile errors in jet_push_macros
generate_push_macrosto use the shim +_innerpatternpanic!()calls withsyn::Error::new_spanned()expect()calls with proper error handling using?unwrap()on parse with proper error handlingChanges Made
Fixed issues from code review:
start_exprvariable that was left after applying the string-based to quote-based macro generation suggestion*start.clone()and*end.clone()tostart.as_ref()andend.as_ref()to avoid unnecessary clonesThe string-based approach is actually the correct one here because we need to generate literal
$tokens in the output macro_rules! definition, which quote! can't do directly.All tests pass, clippy is clean, no warnings.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.