fix: improve stacksafe macro diagnostics - #15
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Improves the #[stacksafe] proc-macro’s error reporting and diagnostics, adds UI coverage for the new diagnostics, and tightens syn dependency configuration to reduce unnecessary features while keeping required parsing/printing support.
Changes:
- Adds targeted diagnostics for
const fnusage and duplicatecrate = ...parameters. - Preserves
synparse errors for malformed functions and improves spans for non-function items. - Adds trybuild UI cases for malformed functions, duplicate parameters, and const functions; updates public docs to note the
const fnlimitation.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| stacksafe/tests/ui/non_function_item.stderr | Updates expected UI output to reflect improved non-function span/labeling. |
| stacksafe/tests/ui/malformed_function.stderr | New expected UI output asserting preserved syn parsing errors. |
| stacksafe/tests/ui/malformed_function.rs | New UI test case for malformed function parsing. |
| stacksafe/tests/ui/duplicate_parameter.stderr | New expected UI output for duplicate crate parameter diagnostics. |
| stacksafe/tests/ui/duplicate_parameter.rs | New UI test case for duplicate crate parameter handling. |
| stacksafe/tests/ui/const_function.stderr | New expected UI output for rejecting const fn. |
| stacksafe/tests/ui/const_function.rs | New UI test case for const fn rejection. |
| stacksafe/src/lib.rs | Documents const fn as a limitation of #[stacksafe]. |
| stacksafe-macro/src/lib.rs | Implements improved parsing/diagnostics (duplicate params, const rejection, better non-function spans, preserved parse errors). |
| stacksafe-macro/Cargo.toml | Enables only required syn features for macro parsing/printing. |
| Cargo.toml | Disables syn default features at the workspace level. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
const fnand duplicatecrate = ...arguments with focused diagnosticsproc_macrotoken conversionconst fnlimitation and add trybuild coverageOut of scope
#[track_caller]behavior is intentionally unchanged and will be handled separatelyTesting
cargo fmt --all -- --checkcargo clippy --all-targets --all-features -- --deny warningscargo test -- --nocapturecargo build --workspace --all-targets --releasecargo +1.85.0 build --workspace --all-targetscargo +1.85.0 test -- --nocapturetaplo checktyposhawkeye checkcargo release -p stacksafe-macro patch --no-publish --no-push --no-tag --no-confirm -vv