-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Fix CRLF line-ending parsing for comments. #25219
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
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @huonw (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see CONTRIBUTING.md for more information. |
let start_bpos = self.last_pos - BytePos(2); | ||
while !self.curr_is('\n') && !self.is_eof() { self.bump(); } | ||
return Some(TokenAndSpan { | ||
Some(TokenAndSpan { | ||
tok: token::Comment, | ||
sp: codemap::mk_sp(start_bpos, self.last_pos) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this start_bpos
is off by one perhaps? It was originally last-BytesPos(2)
but now I think it's last-BytePos(3)
Thanks! Would it be possible to add a test for this as well? |
Ok the bytepos should now be consistent with how it was previously, and I've fixed up the error message change that broke some tests. I've also added a test to check that the newlines are stripped but not sure if this is the best way to do it. |
Hm I believe though that in the first case (a doc comment) the byte pos was subtracted by 3, and in this case it's now subtracted by only two? Perhaps some more assertions could be added to the test that was added about the spans being returned as well? |
Previously the byte pos was |
The branch for doc comments has |
It previously used |
⌛ Testing commit 2dcc200 with merge b948d81... |
Fixes #25182, parser didn't account for \r\n in regular comments, only doc-comments.
Fixes #25182, parser didn't account for \r\n in regular comments, only doc-comments.