Skip to content

Remove the old parser's AST from StatementRewrite#1182

Merged
sgrif merged 1 commit into
mainfrom
sg-remove-old-parser-stmt
Jul 13, 2026
Merged

Remove the old parser's AST from StatementRewrite#1182
sgrif merged 1 commit into
mainfrom
sg-remove-old-parser-stmt

Conversation

@sgrif

@sgrif sgrif commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

It is no longer used, so we can get rid of it. I opted to change the signature of maybe_rewrite to take a mutable reference to the statement rather than copy it and return a new one. This resulted in a significant indentation change, but no actual code changes (beyond replacing a few as_ref and as_muts with stmt and stmt_mut.

It is no longer used, so we can get rid of it. I opted to change the
signature of `maybe_rewrite` to take a mutable reference to the
statement rather than copy it and return a new one. This resulted in a
significant indentation change, but no actual code changes (beyond
replacing a few `as_ref` and `as_mut`s with `stmt` and `stmt_mut`.
@sgrif sgrif requested a review from meskill July 13, 2026 15:26

@levkk levkk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is because we couldn't mutate ASTs before, right? Nice. Bye bye pg_query, say hello to sage_query. No qualms with you naming the library after yourself.

@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@sgrif

sgrif commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

This is because we couldn't mutate ASTs before, right?

No, we could. It's purely a question of where make::owned is called. The reason I opted to move it up a level instead of returning the copied/mutated node from this function is multi-statement ASTs. This function only operates on a single node, but we still need to keep the unmanipulated nodes around, meaning it's not just a question of creating a new single statement list of the transformed node. We'd need to assign it to index 0 in the old list, which requires a mutable reference to it, which requires a make::owned block at that level.

@sgrif sgrif merged commit 5082dba into main Jul 13, 2026
24 checks passed
@sgrif sgrif deleted the sg-remove-old-parser-stmt branch July 13, 2026 15:57
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.

2 participants