Skip to content

Macro hygiene #68

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

Open
Tamschi opened this issue Mar 22, 2025 · 4 comments
Open

Macro hygiene #68

Tamschi opened this issue Mar 22, 2025 · 4 comments

Comments

@Tamschi
Copy link

Tamschi commented Mar 22, 2025

I noticed that the #[trace] macro uses let-bindings in unspanned and call-site-spanned quotes and also refers to items without fully qualified path.

This can lead to hard-to-work-around identifier collisions.
Additionally, (on stable) only mixed-site spans suppress warnings in macro-generated code (as long as the macro is defined outside the current workspace, at least).

@Tamschi
Copy link
Author

Tamschi commented Mar 22, 2025

I'm interested in contributing this improvement, since I have experience with writing hygienic procedural macros, but I'd like to make sure it's wanted first.

@andylokandy
Copy link
Collaborator

Good idea! I'd like to review it if you're willing to submit a PR.

@Tamschi
Copy link
Author

Tamschi commented Mar 22, 2025

I'll see when I have some spare time. I should be able to do this within a month or so, though.

@Tamschi
Copy link
Author

Tamschi commented Apr 13, 2025

I made an attempt, but it seems neither async-trait nor proc-macro-error2 are hygienic, so I can't test this properly.
proc-macro-error2 being somewhat unhygienic also makes it moot to fix these issues here.

I don't currently have the bandwidth to implement macro hygiene for all three crates, so I won't work on it until/unless it becomes a blocker for me. (Consider the attempt abandoned. I'll let you know before I retry.)

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

No branches or pull requests

2 participants