Skip to content
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

ast: Standardize visiting order #126993

Merged
merged 1 commit into from
Jun 27, 2024
Merged

ast: Standardize visiting order #126993

merged 1 commit into from
Jun 27, 2024

Conversation

petrochenkov
Copy link
Contributor

Order: ID, attributes, inner nodes in source order if possible, tokens, span.

Also always use exhaustive matching in visiting infra, and visit some discovered missing nodes.

Unlike #125741 this shouldn't affect anything serious like macro_rules scopes.

Id, attributes, inner nodes in source order if possible, tokens, span.

Also always use exhaustive matching in visiting infra, and visit some missing nodes.
@rustbot
Copy link
Collaborator

rustbot commented Jun 26, 2024

r? @BoxyUwU

rustbot has assigned @BoxyUwU.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot 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. labels Jun 26, 2024
@rustbot
Copy link
Collaborator

rustbot commented Jun 26, 2024

Changes to the size of AST and/or HIR nodes.

cc @nnethercote

@@ -39,37 +39,37 @@ ast-stats-1 - Match 72 ( 1.1%) 1
ast-stats-1 - Struct 72 ( 1.1%) 1
ast-stats-1 - Lit 144 ( 2.2%) 2
ast-stats-1 - Block 216 ( 3.3%) 3
ast-stats-1 PathSegment 720 (10.9%) 30 24
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PathSegment hasn't changed in size. Something about the visitor must have changed, but I can't see what. Do you know?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is relevant, it describes how the AST node measurements aren't perfect:

/// This type measures the size of AST and HIR nodes, by implementing the AST
/// and HIR `Visitor` traits. But we don't measure every visited type because
/// that could cause double counting.
///
/// For example, `ast::Visitor` has `visit_ident`, but `Ident`s are always
/// stored inline within other AST nodes, so we don't implement `visit_ident`
/// here. In contrast, we do implement `visit_expr` because `ast::Expr` is
/// always stored as `P<ast::Expr>`, and every such expression should be
/// measured separately.
///
/// In general, a `visit_foo` method should be implemented here if the
/// corresponding `Foo` type is always stored on its own, e.g.: `P<Foo>`,
/// `Box<Foo>`, `Vec<Foo>`, `Box<[Foo]>`.
///
/// There are some types in the AST and HIR tree that the visitors do not have
/// a `visit_*` method for, and so we cannot measure these, which is
/// unfortunate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Paths in attributes are now visited.

@BoxyUwU
Copy link
Member

BoxyUwU commented Jun 27, 2024

@bors r+ rollup=never

cool :) visitor boilerplate is always kinda sketch when it just uses field accesses instead of exhaustively destructuring

@bors
Copy link
Contributor

bors commented Jun 27, 2024

📌 Commit ba3f681 has been approved by BoxyUwU

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-review Status: Awaiting review from the assignee but also interested parties. labels Jun 27, 2024
@bors
Copy link
Contributor

bors commented Jun 27, 2024

⌛ Testing commit ba3f681 with merge 036b38c...

@bors
Copy link
Contributor

bors commented Jun 27, 2024

☀️ Test successful - checks-actions
Approved by: BoxyUwU
Pushing 036b38c to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 27, 2024
@bors bors merged commit 036b38c into rust-lang:master Jun 27, 2024
7 checks passed
@rustbot rustbot added this to the 1.81.0 milestone Jun 27, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (036b38c): 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.

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

Max RSS (memory usage)

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

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: 696.635s -> 697.296s (0.09%)
Artifact size: 326.80 MiB -> 326.82 MiB (0.01%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants