Skip to content

Migrate_____move_const_to_impl__assist to SyntaxEditor#21791

Open
akashchakrabortymsc-cmd wants to merge 1 commit intorust-lang:masterfrom
akashchakrabortymsc-cmd:migrate-move-const-to-impl
Open

Migrate_____move_const_to_impl__assist to SyntaxEditor#21791
akashchakrabortymsc-cmd wants to merge 1 commit intorust-lang:masterfrom
akashchakrabortymsc-cmd:migrate-move-const-to-impl

Conversation

@akashchakrabortymsc-cmd
Copy link
Contributor

@akashchakrabortymsc-cmd akashchakrabortymsc-cmd commented Mar 9, 2026

part of #18285

Changes

  • Added SyntaxFactory::with_mappings() to the assist closure
  • Replaced indent() with indent_with_mapping(indent, &make)
  • Created SyntaxEditor using builder.make_editor() on the
    original immutable node before clone_for_update()
  • Added editor.add_mappings(make.finish_with_mappings())
  • Added builder.add_file_edits(ctx.vfs_file_id(), editor)

All 12 existing tests pass

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 9, 2026
// If the moved const will be the first item of the impl, add a new line after that.
//
// We're assuming the code is formatted according to Rust's standard style guidelines
// (i.e. no empty lines between impl's `{` token and its first assoc item).
Copy link
Member

Choose a reason for hiding this comment

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

Why delete comments

let const_ = const_.reset_indent();
let const_ = const_.indent(indent);
let const_ = const_.indent_with_mapping(indent, &make);
builder.insert(insert_offset, format!("\n{indent}{const_}{fixup}"));
Copy link
Member

Choose a reason for hiding this comment

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

This is not a migration

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