Skip to content

fix: improve stacksafe macro diagnostics - #15

Merged
tisonkun merged 3 commits into
mainfrom
codex/improve-stacksafe-macro-diagnostics
Jul 27, 2026
Merged

fix: improve stacksafe macro diagnostics#15
tisonkun merged 3 commits into
mainfrom
codex/improve-stacksafe-macro-diagnostics

Conversation

@tisonkun

Copy link
Copy Markdown
Contributor

Summary

  • reject const fn and duplicate crate = ... arguments with focused diagnostics
  • preserve Syn parse errors for malformed functions and improve non-function spans
  • disable unused Syn default features and avoid unnecessary cloning and proc_macro token conversion
  • document the const fn limitation and add trybuild coverage

Out of scope

  • #[track_caller] behavior is intentionally unchanged and will be handled separately

Testing

  • cargo fmt --all -- --check
  • cargo clippy --all-targets --all-features -- --deny warnings
  • cargo test -- --nocapture
  • cargo build --workspace --all-targets --release
  • cargo +1.85.0 build --workspace --all-targets
  • cargo +1.85.0 test -- --nocapture
  • taplo check
  • typos
  • hawkeye check
  • cargo release -p stacksafe-macro patch --no-publish --no-push --no-tag --no-confirm -vv

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 fn usage and duplicate crate = ... parameters.
  • Preserves syn parse 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 fn limitation.

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.

@tisonkun
tisonkun merged commit da3111b into main Jul 27, 2026
12 checks passed
@tisonkun
tisonkun deleted the codex/improve-stacksafe-macro-diagnostics branch July 27, 2026 08:18
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.

2 participants