Skip to content

Make ast validation able to mutate the ast#158998

Draft
oli-obk wants to merge 2 commits into
rust-lang:mainfrom
oli-obk:mut_ast_valid
Draft

Make ast validation able to mutate the ast#158998
oli-obk wants to merge 2 commits into
rust-lang:mainfrom
oli-obk:mut_ast_valid

Conversation

@oli-obk

@oli-obk oli-obk commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Mostly opening for discussion

cc @petrochenkov @jdonszelmann

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

Thoughts?

@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 Jul 9, 2026
@petrochenkov petrochenkov 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants