Skip to content

refactor: break down fastrace-macros#183

Merged
tisonkun merged 5 commits into
mainfrom
separate-macros
Jun 11, 2026
Merged

refactor: break down fastrace-macros#183
tisonkun merged 5 commits into
mainfrom
separate-macros

Conversation

@tisonkun

Copy link
Copy Markdown
Collaborator

No description provided.

tisonkun added 3 commits June 11, 2026 09:24
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>

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

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-macro implementation into args (attribute parsing) and impls (code generation), with lib.rs acting 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.

Comment thread fastrace-macro/src/impls.rs
Comment thread fastrace-macro/src/impls.rs Outdated
tisonkun added 2 commits June 11, 2026 15:15
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>

@zhongzc zhongzc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM if args.rs and impls.rs are pure copy-paste. I haven't checked line by line.

@tisonkun

Copy link
Copy Markdown
Collaborator Author

LGTM if args.rs and impls.rs are pure copy-paste. I haven't checked line by line.

With refactorings. But trybuild tests stay.

@tisonkun tisonkun merged commit 8607f0d into main Jun 11, 2026
11 checks passed
@tisonkun tisonkun deleted the separate-macros branch June 11, 2026 13:44
@tisonkun

Copy link
Copy Markdown
Collaborator Author

With refactorings

In the last three commits.

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.

3 participants