Skip to content

refactor: Change all Visitors to be iterative, child-based#36852

Draft
mgree wants to merge 2 commits into
MaterializeInc:mainfrom
mgree:mir-visitor-iterative
Draft

refactor: Change all Visitors to be iterative, child-based#36852
mgree wants to merge 2 commits into
MaterializeInc:mainfrom
mgree:mir-visitor-iterative

Conversation

@mgree
Copy link
Copy Markdown
Contributor

@mgree mgree commented Jun 1, 2026

Motivation

#36759 (comment)

Description

Changes VisitChildren to have children() and children_mut() functions.

Changes Visitor to use these for iterative traversals.

NB that mutable post-traversal requires unsafety: we need an &mut for the children and an &mut for the parent when we're done. This is sound---Rust allows it when your stack is the call stack, but not your own data structure. So: this is somewhat unsavory code.

Verification

Green CI.

NB maintaing safety in VisitChildren means slightly changing visit order: if we're going to work via children_mut(), we can no longer yield all subqueries before the term itself. This seems to have affected precisely one SLT, which I've rewritten.

@mgree mgree force-pushed the mir-visitor-iterative branch from 9b39e43 to 9ab62e9 Compare June 1, 2026 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant