Skip to content

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

Merged
bors merged 1 commit into
rust-lang:masterfrom
nnethercote:rm-OpenDelim-CloseDelim
Apr 22, 2025
Merged

Remove token::{Open,Close}Delim#139897
bors merged 1 commit into
rust-lang:masterfrom
nnethercote:rm-OpenDelim-CloseDelim

Conversation

@nnethercote

@nnethercotennethercote commented Apr 16, 2025

Copy link
Copy Markdown
Contributor

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

@rustbotrustbot 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
nnethercoteforce-pushed the rm-OpenDelim-CloseDelim branch from f6f6a74 to 8318b85CompareApril 16, 2025 08:41
@rust-log-analyzer

This comment has been minimized.

@nnethercote
nnethercoteforce-pushed the rm-OpenDelim-CloseDelim branch from 8318b85 to 16cfe17CompareApril 16, 2025 09:18
@rust-log-analyzer

This comment has been minimized.

@nnethercote
nnethercoteforce-pushed the rm-OpenDelim-CloseDelim branch from 16cfe17 to d6622d6CompareApril 16, 2025 10:15
@petrochenkovpetrochenkov self-assigned this Apr 16, 2025
@petrochenkovpetrochenkov 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
Copy Markdown
ContributorAuthor

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbotrustbot 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

bors commented Apr 16, 2025

Copy link
Copy Markdown
Collaborator

⌛ Trying commit d6622d6 with merge 448bb73...

@bors

bors commented Apr 16, 2025

Copy link
Copy Markdown
Collaborator

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

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
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.

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

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

meanrangecount
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%)

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

This comment was marked as outdated.

@nnethercote

Copy link
Copy Markdown
ContributorAuthor

Slight perf wins too, that's nice.

@petrochenkovpetrochenkov 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
Comment threadcompiler/rustc_ast/src/token.rs Outdated
Comment threadcompiler/rustc_ast/src/token.rs Outdated
Comment threadcompiler/rustc_expand/src/proc_macro_server.rs Outdated
Comment threadcompiler/rustc_parse/src/lexer/tokentrees.rs Outdated
Comment threadcompiler/rustc_parse/src/parser/path.rs Outdated
Comment threadcompiler/rustc_parse/src/parser/diagnostics.rs Outdated
Comment threadcompiler/rustc_parse/src/parser/expr.rs Outdated
Comment threadcompiler/rustc_parse/src/parser/diagnostics.rs Outdated
Comment threadcompiler/rustc_parse/src/parser/item.rs Outdated
Comment threadcompiler/rustc_parse/src/parser/stmt.rs Outdated
@petrochenkov
petrochenkov marked this pull request as ready for review April 17, 2025 15:06
@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred in src/tools/rustfmt

cc @rust-lang/rustfmt

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann

@rustbotrustbot 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
Copy Markdown
Collaborator

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

@nnethercote
nnethercoteforce-pushed the rm-OpenDelim-CloseDelim branch from d507b13 to 642cfbaCompareApril 17, 2025 22:21
@nnethercote

Copy link
Copy Markdown
ContributorAuthor

I added two new commits.

@nnethercote

Copy link
Copy Markdown
ContributorAuthor

@rustbot ready

@rustbotrustbot 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

jieyouxu commented Apr 18, 2025

Copy link
Copy Markdown
Member

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

@nnethercote
nnethercoteforce-pushed the rm-OpenDelim-CloseDelim branch from 642cfba to a35c855CompareApril 18, 2025 07:00
@nnethercote

Copy link
Copy Markdown
ContributorAuthor

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

Done.

@petrochenkov

Copy link
Copy Markdown
Contributor

r=me after squashing commits.
@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 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
nnethercoteforce-pushed the rm-OpenDelim-CloseDelim branch from a35c855 to bf8ce32CompareApril 20, 2025 21:36
@nnethercote

Copy link
Copy Markdown
ContributorAuthor

I squashed the commits.

@bors r=petrochenkov

@bors

bors commented Apr 20, 2025

Copy link
Copy Markdown
Collaborator

📌 Commit bf8ce32 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 Apr 20, 2025
@bors

bors commented Apr 22, 2025

Copy link
Copy Markdown
Collaborator

⌛ Testing commit bf8ce32 with merge fae7785...

@bors

bors commented Apr 22, 2025

Copy link
Copy Markdown
Collaborator

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

@borsbors added the merged-by-bors This PR was explicitly merged by bors. label Apr 22, 2025
@bors
bors merged commit fae7785 into rust-lang:masterApr 22, 2025
@rustbotrustbot added this to the 1.88.0 milestone Apr 22, 2025
@github-actions

Copy link
Copy Markdown
Contributor
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
Copy Markdown
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.

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

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

meanrangecount
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 freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributesArea: Attributes (`#[…]`, `#![…]`)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@rust-log-analyzer@rust-timer@bors@rustbot@petrochenkov@jieyouxu