Skip to content

Migrate convert_closure_to_fn assist to SyntaxEditor#21790

Open
asuto15 wants to merge 1 commit intorust-lang:masterfrom
asuto15:refactor/convert_closure_to_fn
Open

Migrate convert_closure_to_fn assist to SyntaxEditor#21790
asuto15 wants to merge 1 commit intorust-lang:masterfrom
asuto15:refactor/convert_closure_to_fn

Conversation

@asuto15
Copy link
Contributor

@asuto15 asuto15 commented Mar 9, 2026

part of #15710 and #18285

This PR removes mutable tree editing from convert_closure_to_fn by collecting capture usages from the original closure body and replaying block-modifier cleanup and capture replacements on a cloned body subtree.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 9, 2026
@asuto15 asuto15 changed the title Migrate convert_closure_to_fn assists to SyntaxEditor Migrate convert_closure_to_fn assist to SyntaxEditor Mar 9, 2026
Vec::new(),
);
body_prefix_ranges_to_delete
.extend(token_with_following_whitespace_ranges(&body, gen_token));
Copy link
Member

Choose a reason for hiding this comment

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

Why storage TextRange instead of SyntaxElement?
TextRange operations can easily introduce potential bugs

Suggest calculating TextRange during editing to reduce changes to the original code

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

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants