-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Breaking tokens into pieces should behave similar to Parser::bump. #31455
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @pnkfelix (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. Due to 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 the contribution instructions for more information. |
Thanks! Can you add a test case as well? |
// for tokens currently using `bump_with`, last_token will be of no | ||
// use anyway. | ||
self.last_token = None; | ||
self.last_token_interpolated = self.token.is_interpolated(); |
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.
If you’re setting last_token
to None
, it makes little sense to store whether current token is Interpolated
, right? This probably should be false unconditionally.
I added test based on #24780 and changed last_token_interpolated to be false Initially I was reluctant to add a test for this, because it seems to be |
// expected one of ..., `>`, ... found `>` | ||
// | ||
// compile-flags: -Z parse-only | ||
// error-pattern: expected one of `!`, `::`, `where`, or `{`, found `>` |
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.
We typically use //~ ERROR
instead of error-pattern
as it matches exhaustively and also allows checking span (line number) information
Previously when breaking tokens into smaller pieces, the replace_token function have been used. It replaced current token and updated span information, but it did not clear the list of expected tokens, neither did it update remaining info about last token. This could lead to incorrect error message, like one described in the issue #24780: expected one of ... `>` ... found `>`
Now using |
Previously when breaking tokens into smaller pieces, the replace_token function have been used. It replaced current token and updated span information, but it did not clear the list of expected tokens, neither did it update remaining info about last token. This could lead to incorrect error message, like one described in the issue #24780: expected one of ... `>` ... found `>`
Previously when breaking tokens into smaller pieces, the replace_token
function have been used. It replaced current token and updated span
information, but it did not clear the list of expected tokens, neither
did it update remaining info about last token. This could lead to
incorrect error message, like one described in the issue #24780: