Skip to content

Some parser and AST cleanups - #114353

Merged
bors merged 8 commits into
rust-lang:masterfrom
nnethercote:parser-ast-cleanups
Aug 3, 2023
Merged

Some parser and AST cleanups#114353
bors merged 8 commits into
rust-lang:masterfrom
nnethercote:parser-ast-cleanups

Conversation

@nnethercote

Copy link
Copy Markdown
Contributor

Things I found while looking closely at this code.

r? @petrochenkov

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`.
@rustbotrustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Aug 2, 2023
@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred in src/tools/rustfmt

cc @rust-lang/rustfmt

@rust-log-analyzer

This comment has been minimized.

Comment threadcompiler/rustc_builtin_macros/src/assert.rs Outdated
@petrochenkov

Copy link
Copy Markdown
Contributor

r=me after addressing #114353 (comment) and fixing doc comments.
@rustbot author

@rustbotrustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 2, 2023
@nnethercote

Copy link
Copy Markdown
ContributorAuthor

Thank you for the fast review. I addressed the review comments and fixed the doc comments.

@bors r=petrochenkov rollup

@bors

bors commented Aug 2, 2023

Copy link
Copy Markdown
Collaborator

📌 Commit 60231d6 has been approved by petrochenkov

It is now in the queue for this repository.

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 2, 2023
@rust-log-analyzer

This comment has been minimized.

Noratrieb added a commit to Noratrieb/rust that referenced this pull request Aug 2, 2023
…=petrochenkov
Some parser and AST cleanups
Things I found while looking closely at this code.
r? `@petrochenkov`
@NoratriebNoratrieb mentioned this pull request Aug 2, 2023
@Noratrieb

Copy link
Copy Markdown
Member

@bors r- CI failure

@borsbors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 2, 2023
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.
@nnethercote

Copy link
Copy Markdown
ContributorAuthor

I fixed the rustfmt formatting error.

@bors r=petrochenkov

@bors

bors commented Aug 2, 2023

Copy link
Copy Markdown
Collaborator

📌 Commit d75ee2a has been approved by petrochenkov

It is now in the queue for this repository.

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 2, 2023
@bors

bors commented Aug 3, 2023

Copy link
Copy Markdown
Collaborator

⌛ Testing commit d75ee2a with merge fb31b3c...

@bors

bors commented Aug 3, 2023

Copy link
Copy Markdown
Collaborator

☀️ Test successful - checks-actions
Approved by: petrochenkov
Pushing fb31b3c to master...

@borsbors added the merged-by-bors This PR was explicitly merged by bors. label Aug 3, 2023
@bors
bors merged commit fb31b3c into rust-lang:masterAug 3, 2023
@rustbotrustbot added this to the 1.73.0 milestone Aug 3, 2023
@nnethercote
nnethercote deleted the parser-ast-cleanups branch August 3, 2023 08:53
@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (fb31b3c): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

meanrangecount
Regressions ❌
(primary)
--0
Regressions ❌
(secondary)
--0
Improvements ✅
(primary)
--0
Improvements ✅
(secondary)
-1.0%[-1.7%, -0.6%]5
All ❌✅ (primary)--0

Max RSS (memory usage)

Results

This 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.

meanrangecount
Regressions ❌
(primary)
--0
Regressions ❌
(secondary)
4.3%[1.5%, 7.0%]7
Improvements ✅
(primary)
-2.5%[-2.5%, -2.5%]1
Improvements ✅
(secondary)
-2.3%[-2.3%, -2.3%]1
All ❌✅ (primary)-2.5%[-2.5%, -2.5%]1

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 650.497s -> 647.579s (-0.45%)

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-borsThis PR was explicitly merged by bors.S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@nnethercote@rustbot@rust-log-analyzer@petrochenkov@bors@Noratrieb@rust-timer