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

Preserve spans of all punctuation and keyword tokens in ensure #198

Merged
merged 2 commits into from
Nov 22, 2021

Conversation

dtolnay
Copy link
Owner

@dtolnay dtolnay commented Nov 22, 2021

This uses a technique that has worked well in serde_json::json! — we keep a double copy of the input tokens where we can match punctuation and keywords against one copy and capture the other copy as $:tt.

Relevant for compiler error messages that want to point to punctuation or keyword tokens; without this change the compiler would see the output tokens as originating from inside the macro implementation, rather than what was written by the user, resulting in confusing placement of diagnostics.

@dtolnay dtolnay merged commit 13f8f01 into master Nov 22, 2021
@dtolnay dtolnay deleted the ensure branch November 22, 2021 17:41
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.

1 participant