Migrate convert_from_to_tryfrom assist to SyntaxEditor API#21843
Merged
ChayimFriedman2 merged 1 commit intorust-lang:masterfrom Mar 20, 2026
Merged
Conversation
1134d1c to
8f09c8e
Compare
Shourya742
reviewed
Mar 18, 2026
| use ide_db::{famous_defs::FamousDefs, traits::resolve_target_trait}; | ||
| use syntax::ast::edit::IndentLevel; | ||
| use syntax::ast::{self, AstNode, HasGenericArgs, HasName, make}; | ||
| use syntax::ast::{self, AstNode, HasGenericArgs, HasName, make, syntax_factory::SyntaxFactory}; |
Member
There was a problem hiding this comment.
Can you remove make and replace with methods from syntax_factory.
Contributor
Author
There was a problem hiding this comment.
removed make import, please review.
Replace mutable syntax tree editing (clone_for_update + make::) with the SyntaxFactory API, which is the preferred approach for avoiding mutable tree operations. Changes: - Use SyntaxFactory::with_mappings() instead of bare make:: constructors - Replace make::ty() + .clone_for_update() with make.ty() - Replace make::name() + .clone_for_update() with make.name() - Replace make::ty_alias() + .clone_for_update() with make.ty_alias() - Update wrap_ok() helper to accept &SyntaxFactory and use make.expr_call/arg_list/expr_path - Add editor.add_mappings(make.finish_with_mappings()) to register mappings
8f09c8e to
9db0bd0
Compare
ChayimFriedman2
approved these changes
Mar 20, 2026
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.
Part of #18285.
Migrates the convert_from_to_tryfrom assist from mutable syntax tree
editing (
clone_for_update) to the SyntaxEditor / SyntaxFactory API.Changes
SyntaxFactory::with_mappings()namedmake(following themigration guide in Migrate assists to
SyntaxEditor#18285)make::ty() + .clone_for_update()→make.ty()make::name() + .clone_for_update()→make.name()make::ty_alias() + .clone_for_update()→make.ty_alias()&SyntaxFactoryand usemake.expr_call/make.arg_list/make.expr_patheditor.add_mappings(make.finish_with_mappings())