-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Fix the span information created by TokenStream's FromStr impl #48949
Conversation
This patch makes 3 changes: 1. `StringReader` would not update its `peek_span` or `span` fields when `override_span` was set, so this was moved into a method which updates the internal state. 2. `StringReader` was changed to hold a `DUMMY_SP` instead of a `None` for `override_span`, this decreases the size of `StringReader` and set's us up for (3). 3. `StringReader::mk_sp` was changed to copy the `override_span`'s `SyntaxContext`, even if `override_span` was `DUMMY_SP`. 4. `proc_macro::TokenStream::FromStr` was updated to set the `override_span` to be based on `DUMMY_SP` instead of `call_site`. This means that the line/column information for all tokens in the parsed string will be correct, while also using the call site's hygiene information.
r? @pnkfelix (rust_highfive has picked a reviewer for you, use r? to override) |
r? @jseyfried (I think you're probably the person to review this?) |
Ping from triage, @jseyfried ! |
There are still some tests which are failing which I haven't had the time to figure out, so it's probably ok if you don't get around to reviewing it for a bit. |
Ping from the triage team @mystor! Will you have time to finish this PR in the near future? |
☔ The latest upstream changes (presumably #49154) made this pull request unmergeable. Please resolve the merge conflicts. |
Thank you for this PR @mystor! Unfortunately we haven't heard from you in a while, so I'm going to close this to keep things tidy. Don't worry though, we would be happy to get this merged! If you'll have time in the future to work on this again please reopen the PR, and we'll review it! |
This patch makes 3 changes:
StringReader
would not update itspeek_span
orspan
fields whenoverride_span
was set, so this was moved into a method whichupdates the internal state.
StringReader
was changed to hold aDUMMY_SP
instead of aNone
for
override_span
, this decreases the size ofStringReader
andset's us up for (3).
StringReader::mk_sp
was changed to copy theoverride_span
'sSyntaxContext
, even ifoverride_span
wasDUMMY_SP
.proc_macro::TokenStream::FromStr
was updated to set theoverride_span
to be based onDUMMY_SP
instead ofcall_site
.This means that the line/column information for all tokens in the parsed
string will be correct, while also using the call site's hygiene
information.
Fixes #48944