-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
internal: Migrate ide_assists::utils
and ide_assists::handlers
to use format arg captures (part 1)
#13379
Conversation
2da7fe3
to
0f46f27
Compare
It might be better to convert them slowly instead of making one PR for all 91 of them, which will probably bit rot. |
9e2e071
to
d439fb2
Compare
ide_assists::utils
and ide_assists::handlers
to use format arg captureside_assists::utils
and ide_assists::handlers
to use format arg captures (part 1)
} | ||
|
||
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()); |
There was a problem hiding this comment.
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}"); |
There was a problem hiding this comment.
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.
…=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`
@bors r+ |
☀️ Test successful - checks-actions |
…=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`
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