Skip to content

Conversation

@nnethercote
Copy link
Contributor

r? @ghost

This method always returns one or two token trees. This commit changes
the return type to `(TokenTree, Option<TokenTree>)` to accurately
capture this fact. The new code is also a little faster.
This file uses multiple `TokenStream` and `TokenTree` types.
Confusingly, the non-qualified `TokenStream` is the one from
`rustc_ast`, while the non-qualified `TokenTree` is the one from
`rustc_proc_macro`. This commit removes some `use` items so that more
types are qualified. It's a little more verbose but much clearer.
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 21, 2025
@nnethercote
Copy link
Contributor Author

@bors2 try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Aug 21, 2025
Two small token-related improvements
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 21, 2025
@rust-bors
Copy link

rust-bors bot commented Aug 21, 2025

☀️ Try build successful (CI)
Build commit: acb0dd8 (acb0dd8c7c6a374d49d58dee415229638f5aa078, parent: 125ff8a788c5d6a66917f499abdc00051afe6886)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (acb0dd8): comparison URL.

Overall result: ❌ regressions - no action needed

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

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

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.8% [0.4%, 1.3%] 8
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary 5.3%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
5.3% [5.3%, 5.3%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 5.3% [5.3%, 5.3%] 1

Cycles

Results (secondary -4.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.0% [-4.0%, -4.0%] 1
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 471.807s -> 470.705s (-0.23%)
Artifact size: 378.19 MiB -> 378.28 MiB (0.02%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 21, 2025
@nnethercote
Copy link
Contributor Author

Weird. This was a clear icount win when I measured it locally. PGO, maybe?

@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Aug 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants