Migrate three assists to SyntaxEditor editing#21833
Open
Sangria-hbm wants to merge 2 commits intorust-lang:masterfrom
Open
Migrate three assists to SyntaxEditor editing#21833Sangria-hbm wants to merge 2 commits intorust-lang:masterfrom
Sangria-hbm wants to merge 2 commits intorust-lang:masterfrom
Conversation
Author
|
All CI checks on this PR are now passing. When you have time, could you please take a look and review? Thanks! |
Shourya742
suggested changes
Mar 17, 2026
| AstNode, | ||
| ast::{self, HasGenericParams, HasName, edit::IndentLevel, syntax_factory::SyntaxFactory}, | ||
| ast::{ | ||
| self, HasGenericParams, HasName, edit::IndentLevel, make, syntax_factory::SyntaxFactory, |
Member
There was a problem hiding this comment.
Use SyntaxFactory instead of make. If a required method isn’t available, add it to SyntaxFactory.
Suggested change
| self, HasGenericParams, HasName, edit::IndentLevel, make, syntax_factory::SyntaxFactory, | |
| self, HasGenericParams, HasName, edit::IndentLevel, syntax_factory::SyntaxFactory, |
| use syntax::{ | ||
| ast::{ | ||
| self, AstNode, HasGenericArgs, HasGenericParams, HasName, edit::IndentLevel, | ||
| self, AstNode, HasGenericArgs, HasGenericParams, HasName, edit::IndentLevel, make, |
Member
There was a problem hiding this comment.
Remove make
Suggested change
| self, AstNode, HasGenericArgs, HasGenericParams, HasName, edit::IndentLevel, make, | |
| self, AstNode, HasGenericArgs, HasGenericParams, HasName, edit::IndentLevel, |
Comment on lines
+73
to
+74
| // Record references in the definition file so it can be edited once together | ||
| // with variant and struct-definition updates. |
Member
There was a problem hiding this comment.
Kindly don't change unrelated stuff
Author
|
Thanks for the review — I pushed follow-up commit Changes made:
Could you please take another look when convenient? Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR migrates three
ide-assistshandlers away from mutable-tree editing patterns (ted::*,builder.make_mut,builder.make_syntax_mut) towardSyntaxEditor/SyntaxFactory-based edits.Affected handlers:
extract_struct_from_enum_variantextract_type_aliasgenerate_fn_type_aliasMotivation
This is part of the ongoing migration tracked in #18285 (and related architecture goal in #15710): reducing mutable syntax editing usage so we can continue moving toward cleaner immutable editing internals.
What Changed
extract_struct_from_enum_variantSyntaxEditorandSyntaxFactorymappings.ted::*,builder.make_mut,builder.make_syntax_mut) from this handler.insert_use_with_editor.extract_fix_references_with_turbofish.extract_type_aliasSyntaxFactory::with_mappings+edit.add_mappings(...).(T, T)).dedup_repeated_generic_params.generate_fn_type_aliasSyntaxFactory+ mappedSyntaxEditoredits.selfrendering for unnamed-params alias generation.generate_fn_alias_unnamed_impl_generics_on_self.Testing
Executed in the rust-analyzer workspace:
cargo test -p ide-assists -- handlers::extract_type_alias::tests handlers::generate_fn_type_alias::tests handlers::extract_struct_from_enum_variant::tests cargo fmt -- --checkResult:
68 passed; 0 failedNotes
AI Disclosure
AI tooling was used during drafting/iteration, and all code/tests in this PR were manually reviewed and verified locally.