Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better macro errors for get_struct_fields #17639

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ecoskey
Copy link
Contributor

@ecoskey ecoskey commented Feb 2, 2025

Objective

  • Currently, the error span for get_struct_field when encountering an enum or union points to the macro invocation, rather than the enum or union token. It also doesn't mention which macro reported the error.

Solution

  • Report the correct error span
  • Add parameter for passing in the name of the macro invocation

Testing

Bevy compiles fine with this change

Migration Guide

// before
let fields = get_struct_fields(&ast.data);

// after
let fields = get_struct_fields(&ast.data, "derive(Bundle)");

@ecoskey ecoskey added C-Usability A targeted quality-of-life change that makes Bevy easier to use A-Utils Utility functions and types S-Needs-Review Needs reviewer attention (from anyone!) to move forward D-Macros Code that generates Rust code D-Straightforward Simple bug fixes and API improvements, docs, test and examples labels Feb 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Utils Utility functions and types C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Macros Code that generates Rust code D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant