-
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
parse_tt
refactorings
#94798
Merged
Merged
parse_tt
refactorings
#94798
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
09c3e82
Refactor the second half of `parse_tt`.
nnethercote 4d4baf7
Disallow `TokenTree::{MetaVar,MetaVarExpr}` in matchers.
nnethercote 9f0798b
Add a useful assertion.
nnethercote c13ca42
Move `eof_items` handling entirely within `inner_parse_loop`.
nnethercote 235a87f
Make next_items a `SmallVec`.
nnethercote 95d13fa
Move a `parse_tt` error case into a separate function.
nnethercote File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Not a big deal in the diagnostics code path of course, but the
iter_intersperse
feature could help avoid the intermediateVec<String>
(and still not as good as being able to intersperse an&str
likejoin
allows) with something similar to:(now that I think about it, I'm not sure if
intersperse
clones the separator each time in this situation, and this could be a bad suggestion...)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 see that
intersperse
is used withstr
s elsewhere, so.intersperse(" or ")
should work without theto_string
conversion?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.
This code was pre-existing, I just moved it. It's an error path, and the suggested code isn't shorter or significantly more readable. I don't think a change is necessary.
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.
@petrochenkov IIRC
intersperse
requires the same type as the items, here a list of strings, but this probably could be refactored to work indeed.It doesn't matter much of course in this unlikely code path. It could be nice if someone wanted to do that later (and e.g. turn many of the comments in this file into actual doc comments at the same time). Maybe a tiny fixme would be good ?
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.
Having an issue for replacing all
join
s withintersperse
s where possible would probably be more useful than a FIXME for this specific case.