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

Greatly improve clone! proc macro error output #963

Merged
merged 2 commits into from
Feb 7, 2023

Conversation

GuillaumeGomez
Copy link
Member

@GuillaumeGomez GuillaumeGomez commented Feb 6, 2023

Fixes #956.

What is it this PR doing? Instead of using panic! whenever we encounter an invalid input, it generates a compile_error! call with the span of the token which created the issue to trick the compiler into given the location we want.

Unfortunately, the spans are limited with stable rustc so I can't use Span::join to make it look better in some cases, but I think it remains a great improvement nonetheless.

glib-macros/src/clone.rs Outdated Show resolved Hide resolved
@sdroege sdroege added this to the 0.17.0 milestone Feb 7, 2023
Copy link
Member

@sdroege sdroege left a comment

Choose a reason for hiding this comment

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

Looks good to me otherwise

@GuillaumeGomez
Copy link
Member Author

Updated!

@sdroege sdroege merged commit 602ce5b into gtk-rs:master Feb 7, 2023
@GuillaumeGomez GuillaumeGomez deleted the clone-proc-macro branch February 7, 2023 11:07
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.

[BUG] clone! loses closure arguments span information, leading to poor diagnostics
3 participants