-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Some parser and AST cleanups #114353
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
Some parser and AST cleanups #114353
Conversation
It has a single call site.
This code currently uses a `while` loop and gathers token trees into a vector, but it only succeeds in the case where there is a single token tree. We can instead just call `parse_token_tree` once and then look for `Eof` to detect the success case.
It's more of a `Parser`-level concern than a `TokenCursor`-level concern. Also, `num_bump_calls` is a more accurate name, because it's incremented in `Parser::bump`.
Similar to the last commit, it's more of a `Parser`-level concern than a `TokenCursor`-level concern. And the struct size reductions are nice. After this change, `TokenCursor` is as minimal as possible (two fields and two methods) which is nice.
The `None` variant has already been renamed `Invisible`.
Some changes occurred in src/tools/rustfmt cc @rust-lang/rustfmt |
This comment has been minimized.
This comment has been minimized.
r=me after addressing #114353 (comment) and fixing doc comments. |
69f8ece
to
60231d6
Compare
Thank you for the fast review. I addressed the review comments and fixed the doc comments. @bors r=petrochenkov rollup |
This comment has been minimized.
This comment has been minimized.
…=petrochenkov Some parser and AST cleanups Things I found while looking closely at this code. r? `@petrochenkov`
@bors r- CI failure |
It's the same as `Delimiter`, minus the `Invisible` variant. I'm generally in favour of using types to make impossible states unrepresentable, but this one feels very low-value, and the conversions between the two types are annoying and confusing. Look at the change in `src/tools/rustfmt/src/expr.rs` for an example: the old code converted from `MacDelimiter` to `Delimiter` and back again, for no good reason. This suggests the author was confused about the types.
60231d6
to
d75ee2a
Compare
I fixed the rustfmt formatting error. @bors r=petrochenkov |
☀️ Test successful - checks-actions |
Finished benchmarking commit (fb31b3c): comparison URL. Overall result: ✅ improvements - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 650.497s -> 647.579s (-0.45%) |
Things I found while looking closely at this code.
r? @petrochenkov