Skip to content

Some minor ast validation and visiting cleanups - #158998

Merged
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
oli-obk:mut_ast_valid
Jul 13, 2026
Merged

Some minor ast validation and visiting cleanups#158998
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
oli-obk:mut_ast_valid

Conversation

@oli-obk

@oli-obkoli-obk commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Originally I wanted to mutate the AST during validation, but I will first explore mutating it less and moving more things to arenas. Let's land the parts unrelated to actual mutation.

Original PR description I think this could be useful for having to handle weird cases less later in the compiler. Either by replacing things with error nodes (e.g. ty/expr), or by editing out the invalid elements (`const fn` -> `fn` in trait methods or trait impls).

@rustbotrustbot 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 Jul 9, 2026
@petrochenkovpetrochenkov self-assigned this Jul 9, 2026
@petrochenkov

Copy link
Copy Markdown
Contributor

Either by replacing things with error nodes (e.g. ty/expr), or by editing out the invalid elements (const fn -> fn in trait methods or trait impls).

Can do this in AST lowering, which happens not much later than AST validation?

Historically, the use of mutable AST visitors was minimized to prepare for making AST immutable (or as immutable as possible) and allocating in on arena. Of course nobody ended up having enough resources for this large work.

@oli-obkoli-obk changed the title Make ast validation able to mutate the astSome minor ast validation and visiting cleanupsJul 13, 2026
@oli-obk
oli-obk marked this pull request as ready for review July 13, 2026 14:15
@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 Jul 13, 2026
@oli-obk

Copy link
Copy Markdown
ContributorAuthor

Historically, the use of mutable AST visitors was minimized to prepare for making AST immutable (or as immutable as possible) and allocating in on arena. Of course nobody ended up having enough resources for this large work.

I'll explore doing more things in that direction instead

@petrochenkov

Copy link
Copy Markdown
Contributor

@bors r+ rollup

@rust-bors

rust-borsBot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 03afa49 has been approved by petrochenkov

It is now in the queue for this repository.

@rust-borsrust-borsBot 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 Jul 13, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 13, 2026
Some minor ast validation and visiting cleanups
Originally I wanted to mutate the AST during validation, but I will first explore mutating it less and moving more things to arenas. Let's land the parts unrelated to actual mutation.
<details>
<summary>Original PR description</summary>
I think this could be useful for having to handle weird cases less later in the compiler. Either by replacing things with error nodes (e.g. ty/expr), or by editing out the invalid elements (`const fn` -> `fn` in trait methods or trait impls).
</details>
rust-borsBot pushed a commit that referenced this pull request Jul 13, 2026
…uwer
Rollup of 13 pull requests
Successful merges:
- #159039 (resolve: fix effective visibilities for items in ambiguous glob sets)
- #157706 (Deny `todo!()` in tidy)
- #156712 (Pointer authentication config and user facing options)
- #158535 (Support `#[track_caller]` on EII declarations)
- #158632 (First steps of late-bound turbofishing (place FnDef behind a dummy binder))
- #159002 (Small refactorings in `need_type_info` module)
- #159202 (Bump rustc-demangle to 0.1.28)
- #159216 (Avoid using probe self_ty for delegation arguments)
- #159222 (semicolon_in_expressions_from_macros: Lint on non-local macros too)
- #156609 (Consider structurally impossible Sized predicates in MIR)
- #158854 (Add `#[rustc_test_entrypoint_marker]`)
- #158998 (Some minor ast validation and visiting cleanups)
- #159123 (doc: clarify attr parser APIs)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 13, 2026
Some minor ast validation and visiting cleanups
Originally I wanted to mutate the AST during validation, but I will first explore mutating it less and moving more things to arenas. Let's land the parts unrelated to actual mutation.
<details>
<summary>Original PR description</summary>
I think this could be useful for having to handle weird cases less later in the compiler. Either by replacing things with error nodes (e.g. ty/expr), or by editing out the invalid elements (`const fn` -> `fn` in trait methods or trait impls).
</details>
rust-borsBot pushed a commit that referenced this pull request Jul 13, 2026
…uwer
Rollup of 14 pull requests
Successful merges:
- #159039 (resolve: fix effective visibilities for items in ambiguous glob sets)
- #157706 (Deny `todo!()` in tidy)
- #158535 (Support `#[track_caller]` on EII declarations)
- #158632 (First steps of late-bound turbofishing (place FnDef behind a dummy binder))
- #158846 (Fix unused variable warnings for diverging expressions)
- #159002 (Small refactorings in `need_type_info` module)
- #159202 (Bump rustc-demangle to 0.1.28)
- #159216 (Avoid using probe self_ty for delegation arguments)
- #159222 (semicolon_in_expressions_from_macros: Lint on non-local macros too)
- #156609 (Consider structurally impossible Sized predicates in MIR)
- #157993 (Expose more info about ADTs and functions in rustc_public)
- #158854 (Add `#[rustc_test_entrypoint_marker]`)
- #158998 (Some minor ast validation and visiting cleanups)
- #159123 (doc: clarify attr parser APIs)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 13, 2026
Some minor ast validation and visiting cleanups
Originally I wanted to mutate the AST during validation, but I will first explore mutating it less and moving more things to arenas. Let's land the parts unrelated to actual mutation.
<details>
<summary>Original PR description</summary>
I think this could be useful for having to handle weird cases less later in the compiler. Either by replacing things with error nodes (e.g. ty/expr), or by editing out the invalid elements (`const fn` -> `fn` in trait methods or trait impls).
</details>
rust-borsBot pushed a commit that referenced this pull request Jul 13, 2026
…uwer
Rollup of 15 pull requests
Successful merges:
- #159039 (resolve: fix effective visibilities for items in ambiguous glob sets)
- #157706 (Deny `todo!()` in tidy)
- #156047 (Fix trait method resolution on an adjusted never type)
- #158535 (Support `#[track_caller]` on EII declarations)
- #158632 (First steps of late-bound turbofishing (place FnDef behind a dummy binder))
- #158846 (Fix unused variable warnings for diverging expressions)
- #159002 (Small refactorings in `need_type_info` module)
- #159202 (Bump rustc-demangle to 0.1.28)
- #159216 (Avoid using probe self_ty for delegation arguments)
- #156609 (Consider structurally impossible Sized predicates in MIR)
- #157993 (Expose more info about ADTs and functions in rustc_public)
- #158804 (Clarify `as_uninit_mut` may point to uninitialized memory)
- #158854 (Add `#[rustc_test_entrypoint_marker]`)
- #158998 (Some minor ast validation and visiting cleanups)
- #159123 (doc: clarify attr parser APIs)
@JonathanBrouwer

Copy link
Copy Markdown
Member

@bors try jobs=x86_64-gnu-llvm-22-3

@rust-bors

This comment has been minimized.

rust-borsBot pushed a commit that referenced this pull request Jul 13, 2026
Some minor ast validation and visiting cleanups
try-job: x86_64-gnu-llvm-22-3
rust-borsBot pushed a commit that referenced this pull request Jul 13, 2026
…uwer
Rollup of 13 pull requests
Successful merges:
- #157706 (Deny `todo!()` in tidy)
- #158535 (Support `#[track_caller]` on EII declarations)
- #158632 (First steps of late-bound turbofishing (place FnDef behind a dummy binder))
- #158846 (Fix unused variable warnings for diverging expressions)
- #159002 (Small refactorings in `need_type_info` module)
- #159202 (Bump rustc-demangle to 0.1.28)
- #159216 (Avoid using probe self_ty for delegation arguments)
- #156609 (Consider structurally impossible Sized predicates in MIR)
- #157993 (Expose more info about ADTs and functions in rustc_public)
- #158804 (Clarify `as_uninit_mut` may point to uninitialized memory)
- #158854 (Add `#[rustc_test_entrypoint_marker]`)
- #158998 (Some minor ast validation and visiting cleanups)
- #159123 (doc: clarify attr parser APIs)
@rust-bors

rust-borsBot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 49b2692 (49b269221a11079e712097ec30327062c5932345)
Base parent: 225e91c (225e91c03da22cd4b9792b83c1cfc97967101614)

@rust-bors
rust-borsBot merged commit 34d04a5 into rust-lang:mainJul 13, 2026
14 checks passed
@rustbotrustbot added this to the 1.99.0 milestone Jul 13, 2026
rust-timer added a commit that referenced this pull request Jul 13, 2026
Rollup merge of #158998 - oli-obk:mut_ast_valid, r=petrochenkov
Some minor ast validation and visiting cleanups
Originally I wanted to mutate the AST during validation, but I will first explore mutating it less and moving more things to arenas. Let's land the parts unrelated to actual mutation.
<details>
<summary>Original PR description</summary>
I think this could be useful for having to handle weird cases less later in the compiler. Either by replacing things with error nodes (e.g. ty/expr), or by editing out the invalid elements (`const fn` -> `fn` in trait methods or trait impls).
</details>
github-actionsBot pushed a commit to rust-lang/stdarch that referenced this pull request Jul 16, 2026
…uwer
Rollup of 13 pull requests
Successful merges:
- rust-lang/rust#157706 (Deny `todo!()` in tidy)
- rust-lang/rust#158535 (Support `#[track_caller]` on EII declarations)
- rust-lang/rust#158632 (First steps of late-bound turbofishing (place FnDef behind a dummy binder))
- rust-lang/rust#158846 (Fix unused variable warnings for diverging expressions)
- rust-lang/rust#159002 (Small refactorings in `need_type_info` module)
- rust-lang/rust#159202 (Bump rustc-demangle to 0.1.28)
- rust-lang/rust#159216 (Avoid using probe self_ty for delegation arguments)
- rust-lang/rust#156609 (Consider structurally impossible Sized predicates in MIR)
- rust-lang/rust#157993 (Expose more info about ADTs and functions in rustc_public)
- rust-lang/rust#158804 (Clarify `as_uninit_mut` may point to uninitialized memory)
- rust-lang/rust#158854 (Add `#[rustc_test_entrypoint_marker]`)
- rust-lang/rust#158998 (Some minor ast validation and visiting cleanups)
- rust-lang/rust#159123 (doc: clarify attr parser APIs)
@Kobzol

Copy link
Copy Markdown
Member

@rust-timer build be6cb91

For #159246.

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (be6cb91): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

@bors rollup=never rustc-perf
@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.

meanrangecount
Regressions ❌
(primary)
--0
Regressions ❌
(secondary)
--0
Improvements ✅
(primary)
--0
Improvements ✅
(secondary)
-1.8%[-2.5%, -0.5%]14
All ❌✅ (primary)--0

Max RSS (memory usage)

Results (primary 2.2%, secondary -20.0%)

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

meanrangecount
Regressions ❌
(primary)
2.2%[2.2%, 2.2%]1
Regressions ❌
(secondary)
--0
Improvements ✅
(primary)
--0
Improvements ✅
(secondary)
-20.0%[-23.2%, -11.6%]13
All ❌✅ (primary)2.2%[2.2%, 2.2%]1

Cycles

Results (secondary -14.4%)

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

meanrangecount
Regressions ❌
(primary)
--0
Regressions ❌
(secondary)
--0
Improvements ✅
(primary)
--0
Improvements ✅
(secondary)
-14.4%[-19.6%, -6.4%]13
All ❌✅ (primary)--0

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 488.117s -> 487.409s (-0.15%)
Artifact size: 389.87 MiB -> 389.87 MiB (-0.00%)

Kobzol pushed a commit to Kobzol/rustc_codegen_cranelift that referenced this pull request Jul 23, 2026
…uwer
Rollup of 13 pull requests
Successful merges:
- rust-lang/rust#157706 (Deny `todo!()` in tidy)
- rust-lang/rust#158535 (Support `#[track_caller]` on EII declarations)
- rust-lang/rust#158632 (First steps of late-bound turbofishing (place FnDef behind a dummy binder))
- rust-lang/rust#158846 (Fix unused variable warnings for diverging expressions)
- rust-lang/rust#159002 (Small refactorings in `need_type_info` module)
- rust-lang/rust#159202 (Bump rustc-demangle to 0.1.28)
- rust-lang/rust#159216 (Avoid using probe self_ty for delegation arguments)
- rust-lang/rust#156609 (Consider structurally impossible Sized predicates in MIR)
- rust-lang/rust#157993 (Expose more info about ADTs and functions in rustc_public)
- rust-lang/rust#158804 (Clarify `as_uninit_mut` may point to uninitialized memory)
- rust-lang/rust#158854 (Add `#[rustc_test_entrypoint_marker]`)
- rust-lang/rust#158998 (Some minor ast validation and visiting cleanups)
- rust-lang/rust#159123 (doc: clarify attr parser APIs)
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request Aug 17, 2026
…uwer
Rollup of 13 pull requests
Successful merges:
- rust-lang/rust#157706 (Deny `todo!()` in tidy)
- rust-lang/rust#158535 (Support `#[track_caller]` on EII declarations)
- rust-lang/rust#158632 (First steps of late-bound turbofishing (place FnDef behind a dummy binder))
- rust-lang/rust#158846 (Fix unused variable warnings for diverging expressions)
- rust-lang/rust#159002 (Small refactorings in `need_type_info` module)
- rust-lang/rust#159202 (Bump rustc-demangle to 0.1.28)
- rust-lang/rust#159216 (Avoid using probe self_ty for delegation arguments)
- rust-lang/rust#156609 (Consider structurally impossible Sized predicates in MIR)
- rust-lang/rust#157993 (Expose more info about ADTs and functions in rustc_public)
- rust-lang/rust#158804 (Clarify `as_uninit_mut` may point to uninitialized memory)
- rust-lang/rust#158854 (Add `#[rustc_test_entrypoint_marker]`)
- rust-lang/rust#158998 (Some minor ast validation and visiting cleanups)
- rust-lang/rust#159123 (doc: clarify attr parser APIs)
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@oli-obk@petrochenkov@JonathanBrouwer@Kobzol@rust-timer@rustbot