Skip to content

Remove token::{Open,Close}Delim #139897

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

Merged
merged 1 commit into from
Apr 22, 2025

Conversation

nnethercote
Copy link
Contributor

@nnethercote nnethercote commented Apr 16, 2025

By replacing them with {Open,Close}{Param,Brace,Bracket,Invisible}.

PR #137902 made ast::TokenKind more like lexer::TokenKind by
replacing the compound BinOp{,Eq}(BinOpToken) variants with fieldless
variants Plus, Minus, Star, etc. This commit does a similar thing
with delimiters. It also makes ast::TokenKind more similar to
parser::TokenType.

This requires a few new methods:

  • TokenKind::is_{,open_,close_}delim() replace various kinds of
    pattern matches.
  • Delimiter::as_{open,close}_token_kind are used to convert
    Delimiter values to TokenKind.

Despite these additions, it's a net reduction in lines of code. This is
because e.g. token::OpenParen is so much shorter than
token::OpenDelim(Delimiter::Parenthesis) that many multi-line forms
reduce to single line forms. And many places where the number of lines
doesn't change are still easier to read, just because the names are
shorter, e.g.:

-   } else if self.token != token::CloseDelim(Delimiter::Brace) {
+   } else if self.token != token::CloseBrace {

r? @petrochenkov

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) 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 Apr 16, 2025
@rust-log-analyzer

This comment has been minimized.

@nnethercote nnethercote force-pushed the rm-OpenDelim-CloseDelim branch from f6f6a74 to 8318b85 Compare April 16, 2025 08:41
@rust-log-analyzer

This comment has been minimized.

@nnethercote nnethercote force-pushed the rm-OpenDelim-CloseDelim branch from 8318b85 to 16cfe17 Compare April 16, 2025 09:18
@rust-log-analyzer

This comment has been minimized.

@nnethercote nnethercote force-pushed the rm-OpenDelim-CloseDelim branch from 16cfe17 to d6622d6 Compare April 16, 2025 10:15
@petrochenkov petrochenkov self-assigned this Apr 16, 2025
@petrochenkov petrochenkov 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 Apr 16, 2025
@nnethercote
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 16, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 16, 2025
… r=<try>

Remove `token::{Open,Close}Delim`

r? `@ghost`
@bors
Copy link
Collaborator

bors commented Apr 16, 2025

⌛ Trying commit d6622d6 with merge 448bb73...

@bors
Copy link
Collaborator

bors commented Apr 16, 2025

☀️ Try build successful - checks-actions
Build commit: 448bb73 (448bb7314ad82fe33016e188f27ebe57376d93cd)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (448bb73): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.4% [-0.5%, -0.2%] 14
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.4% [-0.5%, -0.2%] 14

Max RSS (memory usage)

Results (primary -0.4%)

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.

mean range count
Regressions ❌
(primary)
2.8% [2.8%, 2.8%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.7% [-1.1%, -0.4%] 10
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.4% [-1.1%, 2.8%] 11

Cycles

Results (primary -0.6%)

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.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.6% [-0.7%, -0.4%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.6% [-0.7%, -0.4%] 2

Binary size

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

Bootstrap: 776.859s -> 775.51s (-0.17%)
Artifact size: 364.72 MiB -> 364.80 MiB (0.02%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 16, 2025
@nnethercote nnethercote force-pushed the rm-OpenDelim-CloseDelim branch from d6622d6 to d507b13 Compare April 17, 2025 00:49
@rustbot

This comment was marked as outdated.

@nnethercote
Copy link
Contributor Author

Slight perf wins too, that's nice.

@petrochenkov petrochenkov added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 17, 2025
@petrochenkov petrochenkov marked this pull request as ready for review April 17, 2025 15:06
@rustbot
Copy link
Collaborator

rustbot commented Apr 17, 2025

Some changes occurred in src/tools/rustfmt

cc @rust-lang/rustfmt

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann

@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Apr 17, 2025
@rustbot
Copy link
Collaborator

rustbot commented Apr 17, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@nnethercote nnethercote force-pushed the rm-OpenDelim-CloseDelim branch from d507b13 to 642cfba Compare April 17, 2025 22:21
@nnethercote
Copy link
Contributor Author

I added two new commits.

@nnethercote
Copy link
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 17, 2025
@jieyouxu
Copy link
Member

jieyouxu commented Apr 18, 2025

Can you drop the diff removal commit (since there's #139991 already)?

@nnethercote nnethercote force-pushed the rm-OpenDelim-CloseDelim branch from 642cfba to a35c855 Compare April 18, 2025 07:00
@nnethercote
Copy link
Contributor Author

Can you drop the diff removal commit (since there's #139991 already)?

Done.

@petrochenkov
Copy link
Contributor

r=me after squashing commits.
@rustbot author

@rustbot rustbot 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 Apr 18, 2025
By replacing them with `{Open,Close}{Param,Brace,Bracket,Invisible}`.

PR rust-lang#137902 made `ast::TokenKind` more like `lexer::TokenKind` by
replacing the compound `BinOp{,Eq}(BinOpToken)` variants with fieldless
variants `Plus`, `Minus`, `Star`, etc. This commit does a similar thing
with delimiters. It also makes `ast::TokenKind` more similar to
`parser::TokenType`.

This requires a few new methods:
- `TokenKind::is_{,open_,close_}delim()` replace various kinds of
  pattern matches.
- `Delimiter::as_{open,close}_token_kind` are used to convert
  `Delimiter` values to `TokenKind`.

Despite these additions, it's a net reduction in lines of code. This is
because e.g. `token::OpenParen` is so much shorter than
`token::OpenDelim(Delimiter::Parenthesis)` that many multi-line forms
reduce to single line forms. And many places where the number of lines
doesn't change are still easier to read, just because the names are
shorter, e.g.:
```
-   } else if self.token != token::CloseDelim(Delimiter::Brace) {
+   } else if self.token != token::CloseBrace {
```
@nnethercote nnethercote force-pushed the rm-OpenDelim-CloseDelim branch from a35c855 to bf8ce32 Compare April 20, 2025 21:36
@nnethercote
Copy link
Contributor Author

I squashed the commits.

@bors r=petrochenkov

@bors
Copy link
Collaborator

bors commented Apr 20, 2025

📌 Commit bf8ce32 has been approved by petrochenkov

It is now in the queue for this repository.

@bors bors 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 Apr 20, 2025
@bors
Copy link
Collaborator

bors commented Apr 22, 2025

⌛ Testing commit bf8ce32 with merge fae7785...

@bors
Copy link
Collaborator

bors commented Apr 22, 2025

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

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 22, 2025
@bors bors merged commit fae7785 into rust-lang:master Apr 22, 2025
7 checks passed
@rustbot rustbot added this to the 1.88.0 milestone Apr 22, 2025
Copy link

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing d6c1e45 (parent) -> fae7785 (this PR)

Test differences

Show 20 test diffs

20 doctest diffs were found. These are ignored, as they are noisy.

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard fae7785b60ea7fe1ad293352c057a5b7be73d245 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. x86_64-apple-1: 7008.7s -> 11590.5s (65.4%)
  2. x86_64-apple-2: 8031.9s -> 3889.3s (-51.6%)
  3. dist-apple-various: 6570.7s -> 7874.4s (19.8%)
  4. aarch64-apple: 4822.6s -> 3928.1s (-18.5%)
  5. x86_64-gnu-llvm-20-1: 6328.4s -> 5195.9s (-17.9%)
  6. dist-riscv64-linux: 5313.8s -> 5867.9s (10.4%)
  7. dist-x86_64-apple: 10849.1s -> 11641.8s (7.3%)
  8. x86_64-msvc-2: 7263.4s -> 6775.7s (-6.7%)
  9. x86_64-gnu-llvm-19-3: 7010.5s -> 6622.7s (-5.5%)
  10. dist-loongarch64-musl: 5343.8s -> 5129.0s (-4.0%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (fae7785): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.4% [-0.6%, -0.2%] 14
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.4% [-0.6%, -0.2%] 14

Max RSS (memory usage)

Results (primary 0.3%, secondary 3.4%)

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.

mean range count
Regressions ❌
(primary)
0.7% [0.5%, 1.0%] 10
Regressions ❌
(secondary)
3.4% [3.4%, 3.4%] 1
Improvements ✅
(primary)
-1.8% [-2.0%, -1.5%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.3% [-2.0%, 1.0%] 12

Cycles

Results (primary -0.6%, secondary 1.8%)

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.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.4% [2.1%, 3.0%] 6
Improvements ✅
(primary)
-0.6% [-0.6%, -0.5%] 2
Improvements ✅
(secondary)
-1.6% [-1.6%, -1.6%] 1
All ❌✅ (primary) -0.6% [-0.6%, -0.5%] 2

Binary size

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

Bootstrap: 774.01s -> 775.257s (0.16%)
Artifact size: 365.04 MiB -> 365.06 MiB (0.01%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants