Skip to content

internal: Migrate ide_assists::utils and ide_assists::handlers to use format arg captures (part 1) #13379

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 5, 2022

Conversation

DropDemBits
Copy link
Contributor

@DropDemBits DropDemBits commented Oct 10, 2022

This not only serves as making future migration to mutable syntax trees easier, it also finds out what needs to be migrated in the first place.

Aside from the first commit, subsequent commits are structured to only deal with one file/handler at a time.

This is the first of 3 PRs, migrating:

Utils:

  • gen_trait_fn_body
  • render_snippet
  • ReferenceConversion
    • convert_type
    • getter

Handlers:

  • add_explicit_type
  • add_return_type
  • add_turbo_fish
  • apply_demorgan
  • auto_import
  • convert_comment_block
  • convert_integer_literal
  • convert_into_to_from
  • convert_iter_for_each_to_for
  • convert_let_else_to_match
  • convert_tuple_struct_to_named_struct
  • convert_two_arm_bool_match_to_matches_macro
  • destructure_tuple_binding
  • extract_function
  • extract_module
  • extract_struct_from_enum_variant
  • extract_type_alias
  • extract_variable
  • fix_visibility

@DropDemBits DropDemBits force-pushed the ide-assists-format-args-capture branch from 2da7fe3 to 0f46f27 Compare October 10, 2022 14:48
@lnicola
Copy link
Member

lnicola commented Oct 10, 2022

It might be better to convert them slowly instead of making one PR for all 91 of them, which will probably bit rot.

@DropDemBits DropDemBits force-pushed the ide-assists-format-args-capture branch from 9e2e071 to d439fb2 Compare October 10, 2022 19:56
@DropDemBits DropDemBits changed the title internal: Migrate ide_assists::utils and ide_assists::handlers to use format arg captures internal: Migrate ide_assists::utils and ide_assists::handlers to use format arg captures (part 1) Oct 10, 2022
@DropDemBits DropDemBits marked this pull request as ready for review October 10, 2022 20:50
}

for term in terms {
let term_range = term.syntax().text_range();
let not_term = invert_boolean_expression(term);
edit.replace(term_range, not_term.syntax().text());
edit.replace(term_range, not_term.to_string());
Copy link
Member

Choose a reason for hiding this comment

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

I thought this introduces an extra allocation, but replace takes Into<String> anyway.

// Appends the type suffix back into the new literal if it exists.
if let Some(suffix) = suffix {
converted.push_str(suffix);
}

let label = format!("Convert {literal} to {converted}");
Copy link
Member

Choose a reason for hiding this comment

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

Nit: might as well push_str to label instead of using format!. But it's not like this is perf-sensitive either.

bors added a commit that referenced this pull request Oct 17, 2022
…=Veykril

Migrate assists to format args captures, part 2

Continuation of #13379

Migrates:

- `generate_constant`
- `generate_default_from_enum_variant`
- `generate_default_from_new`
- `generate_delegate_methods`
- `generate_deref`
- `generate_documentation_template`
- `generate_enum_is_method`
- `generate_enum_projection_method`
- `generate_from_impl_for_enum`
- `generate_function`
- `generate_getter`
- `generate_impl`
- `generate_new`
- `generate_setter`
@Veykril Veykril added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 3, 2022
@Veykril
Copy link
Member

Veykril commented Nov 5, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Nov 5, 2022

📌 Commit d439fb2 has been approved by Veykril

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Nov 5, 2022

⌛ Testing commit d439fb2 with merge afe8f6b...

@bors
Copy link
Contributor

bors commented Nov 5, 2022

☀️ Test successful - checks-actions
Approved by: Veykril
Pushing afe8f6b to master...

@bors bors merged commit afe8f6b into rust-lang:master Nov 5, 2022
bors added a commit that referenced this pull request Nov 5, 2022
…=Veykril

Migrate assists to format args captures, part 3

Continuation of #13379

Migrates:

- `inline_call`
- `inline_local_variable`
- `introduce_named_lifetime`
- `merge_match_arms`
- `move_from_mod_rs`
- `move_guard`
- `move_module_to_file`
- `move_to_mod_rs`
- `number_representation`
- `qualify_method_call`
- `qualify_path`
- `raw_string`
- `remove_dbg`
- `replace_derive_with_manual_impl`
- `replace_or_with_or_else`
- `replace_turbofish_with_explicit_type`
- `unwrap_tuple`
- `wrap_return_type_in_result`
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.

4 participants