refactor: break down fastrace-macros#183
Merged
Merged
Conversation
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR refactors the fastrace-macro crate by splitting parsing and expansion logic into dedicated modules, and adds UI tests to validate macro behavior across additional function signature patterns and error cases.
Changes:
- Split
fastrace-macroimplementation intoargs(attribute parsing) andimpls(code generation), withlib.rsacting as the entrypoint. - Expand macro UI “ok” coverage to include methods, generics/
impl Trait,unsafe extern "C"fns, and sync properties formatting/escaping. - Add new UI “err” fixtures to validate diagnostics for invalid arguments (wrong literal types, missing braces, unknown args, duplicate properties).
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/macros/tests/ui/ok/has-unsafe-extern.rs | UI pass test for unsafe extern "C" function signatures under #[trace]. |
| tests/macros/tests/ui/ok/has-sync-properties.rs | UI pass test for properties parsing and formatting/escaping behavior. |
| tests/macros/tests/ui/ok/has-methods.rs | UI pass test for applying #[trace] to impl methods (sync + async). |
| tests/macros/tests/ui/ok/has-generic-signatures.rs | UI pass test for generics and async returning impl Trait (covers impl-trait erasure logic). |
| tests/macros/tests/ui/err/short-name-is-not-bool.rs | UI compile-fail test for invalid short_name literal type. |
| tests/macros/tests/ui/err/short-name-is-not-bool.stderr | Expected diagnostic output for invalid short_name literal type. |
| tests/macros/tests/ui/err/properties-value-non-string.rs | UI compile-fail test for non-string property value. |
| tests/macros/tests/ui/err/properties-value-non-string.stderr | Expected diagnostic output for non-string property value. |
| tests/macros/tests/ui/err/properties-missing-braces.rs | UI compile-fail test for properties missing { ... } braces. |
| tests/macros/tests/ui/err/properties-missing-braces.stderr | Expected diagnostic output for properties missing braces. |
| tests/macros/tests/ui/err/name-is-not-string.rs | UI compile-fail test for invalid name literal type. |
| tests/macros/tests/ui/err/name-is-not-string.stderr | Expected diagnostic output for invalid name literal type. |
| tests/macros/tests/ui/err/has-unknown-argument.rs | UI compile-fail test for unknown attribute argument. |
| tests/macros/tests/ui/err/has-unknown-argument.stderr | Expected diagnostic output for unknown attribute argument. |
| tests/macros/tests/ui/err/has-duplicated-properties.rs | UI compile-fail test for duplicate property keys. |
| tests/macros/tests/ui/err/has-duplicated-properties.stderr | Expected diagnostic output for duplicate property keys. |
| fastrace-macro/src/lib.rs | Refactor entrypoint: delegates parsing to args and expansion to impls behind the enable feature. |
| fastrace-macro/src/impls.rs | New module containing trace expansion logic extracted from lib.rs. |
| fastrace-macro/src/args.rs | New module containing attribute argument parsing (including duplicate detection). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
zhongzc
approved these changes
Jun 11, 2026
zhongzc
left a comment
Collaborator
There was a problem hiding this comment.
LGTM if args.rs and impls.rs are pure copy-paste. I haven't checked line by line.
Collaborator
Author
With refactorings. But trybuild tests stay. |
Collaborator
Author
In the last three commits. |
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.
No description provided.