rust-analyzer/crates/ide-assists/src/handlers
Sebastian Ziebell c0e9b57371 Improve assist to filter invalid params
The change updates the logic to determine if a function parameter is
valid for replacing the type param with the trait implementation.

First all usages are determined, to check if they are used outside the function
parameter list. If an outside reference is found, e.g. in body, return type or
where clause, the assist is skipped. All remaining usages only appear in the
function param list. For each usage the param type is checked to see if
it's valid.

**Please note** the logic currently follows a heuristic and may not cover
all existing parameter declarations.

* determine valid usage references by checking ancestors (on AST level)
* split test into separate ones
2023-06-02 12:46:01 +02:00
..
add_braces.rs fixes 2023-01-21 23:42:11 +05:30
add_explicit_type.rs Add flag to disallow opaque types for DisplayTarget::SourceCode 2023-04-12 19:03:48 +09:00
add_label_to_loop.rs Run cargo fix --edition-idioms 2022-07-20 15:02:08 +02:00
add_lifetime_to_type.rs Run cargo fix --edition-idioms 2022-07-20 15:02:08 +02:00
add_missing_impl_members.rs Auto merge of #14881 - Veykril:name-display, r=Veykril 2023-05-25 12:04:16 +00:00
add_missing_match_arms.rs Simplify 2023-03-28 16:32:26 +02:00
add_return_type.rs fix some typos 2023-05-01 14:53:25 +08:00
add_turbo_fish.rs Migrate assists to format args captures, part 1 2022-10-10 15:56:21 -04:00
apply_demorgan.rs Migrate assists to format args captures, part 1 2022-10-10 15:56:21 -04:00
auto_import.rs internal: Replace Display impl for Name 2023-05-24 20:55:12 +02:00
change_visibility.rs Run cargo fix --edition-idioms 2022-07-20 15:02:08 +02:00
convert_bool_then.rs internal: Replace Display impl for Name 2023-05-24 20:55:12 +02:00
convert_comment_block.rs Convert pub to pub(crate) 2023-01-12 09:54:48 +01:00
convert_integer_literal.rs Migrate assists to format args captures, part 1 2022-10-10 15:56:21 -04:00
convert_into_to_from.rs Migrate assists to format args captures, part 1 2022-10-10 15:56:21 -04:00
convert_iter_for_each_to_for.rs internal: Replace Display impl for Name 2023-05-24 20:55:12 +02:00
convert_let_else_to_match.rs Simplify 2023-03-28 16:32:26 +02:00
convert_match_to_let_else.rs Simplify 2023-03-28 16:32:26 +02:00
convert_named_struct_to_tuple_struct.rs Add render configs for memory layout hovers 2023-05-30 18:36:06 +02:00
convert_nested_function_to_closure.rs Address another round of review comments 2023-04-05 18:48:21 +02:00
convert_to_guarded_return.rs Spelling 2023-04-19 09:45:55 -04:00
convert_tuple_struct_to_named_struct.rs Add render configs for memory layout hovers 2023-05-30 18:36:06 +02:00
convert_two_arm_bool_match_to_matches_macro.rs Migrate assists to format args captures, part 1 2022-10-10 15:56:21 -04:00
convert_while_to_loop.rs Run cargo fix --edition-idioms 2022-07-20 15:02:08 +02:00
destructure_tuple_binding.rs Fix pattern type mismatch in tuples 2023-05-04 16:03:36 +03:30
desugar_doc_comment.rs move required_hashes into utils 2023-01-16 18:39:16 +01:00
expand_glob_import.rs internal: Replace Display impl for Name 2023-05-24 20:55:12 +02:00
extract_expressions_from_format_string.rs docs: update assist comment 2023-01-09 12:23:06 +01:00
extract_function.rs MIR episode 6 2023-05-28 23:25:15 +03:30
extract_module.rs internal: Replace Display impl for Name 2023-05-24 20:55:12 +02:00
extract_struct_from_enum_variant.rs internal: Replace Display impl for Name 2023-05-24 20:55:12 +02:00
extract_type_alias.rs Use the fact that Either: AstNode 2023-01-14 15:20:32 +00:00
extract_variable.rs fix: Fix receiver adjustments for extract_variable assist 2023-04-11 14:01:23 +02:00
fix_visibility.rs internal: Replace Display impl for Name 2023-05-24 20:55:12 +02:00
flip_binexpr.rs Run cargo fix --edition-idioms 2022-07-20 15:02:08 +02:00
flip_comma.rs Run cargo fix --edition-idioms 2022-07-20 15:02:08 +02:00
flip_trait_bound.rs Run cargo fix --edition-idioms 2022-07-20 15:02:08 +02:00
generate_constant.rs Add flag to disallow opaque types for DisplayTarget::SourceCode 2023-04-12 19:03:48 +09:00
generate_default_from_enum_variant.rs Migrate assists to format args captures, part 2 2022-10-12 02:23:35 -04:00
generate_default_from_new.rs a number of code simplifications 2023-01-10 18:48:51 +00:00
generate_delegate_methods.rs Auto merge of #14842 - alibektas:internal/ast-make-improve, r=Veykril 2023-05-30 16:09:46 +00:00
generate_deref.rs internal: Replace Display impl for Name 2023-05-24 20:55:12 +02:00
generate_derive.rs generate_derive no longer breaks indentation 2023-05-10 16:35:43 +04:00
generate_documentation_template.rs Spelling 2023-04-19 09:45:55 -04:00
generate_enum_is_method.rs feat: add multiple getters mode in generate_getter 2022-10-20 16:47:23 +05:30
generate_enum_projection_method.rs Inline all format arguments where possible 2022-12-24 14:36:10 -05:00
generate_enum_variant.rs Add flag to disallow opaque types for DisplayTarget::SourceCode 2023-04-12 19:03:48 +09:00
generate_from_impl_for_enum.rs refactor: use generate_trait_impl_text_intransitive for From-like traits 2022-12-17 22:59:30 +08:00
generate_function.rs Auto merge of #14842 - alibektas:internal/ast-make-improve, r=Veykril 2023-05-30 16:09:46 +00:00
generate_getter.rs Spelling 2023-04-19 09:45:55 -04:00
generate_impl.rs refactor: use generate_trait_impl_text_intransitive for From-like traits 2022-12-17 22:59:30 +08:00
generate_is_empty_from_len.rs Simplify 2023-02-27 15:51:45 +01:00
generate_new.rs Spelling 2023-04-19 09:45:55 -04:00
generate_setter.rs feat: add multiple getters mode in generate_getter 2022-10-20 16:47:23 +05:30
inline_call.rs fix: don't replace SyntaxToken with SyntaxNode 2023-03-15 17:18:09 +09:00
inline_local_variable.rs Add BindingId 2023-03-06 21:09:08 +03:30
inline_macro.rs Spelling 2023-04-19 09:45:55 -04:00
inline_type_alias.rs remove needless borrows 2023-01-02 14:52:32 +00:00
introduce_named_generic.rs fix: Move cursor before generated generic 2023-03-26 18:10:41 -04:00
introduce_named_lifetime.rs Spelling 2023-04-19 09:45:55 -04:00
invert_if.rs Run cargo fix --edition-idioms 2022-07-20 15:02:08 +02:00
merge_imports.rs a number of code simplifications 2023-01-10 18:48:51 +00:00
merge_match_arms.rs Fix pattern type mismatch in tuples 2023-05-04 16:03:36 +03:30
move_bounds.rs Fmt 2022-09-02 21:18:36 +00:00
move_const_to_impl.rs internal: Replace Display impl for Name 2023-05-24 20:55:12 +02:00
move_from_mod_rs.rs internal: Replace Display impl for Name 2023-05-24 20:55:12 +02:00
move_guard.rs Migrate assists to format args captures, part 3 2022-10-12 02:28:41 -04:00
move_module_to_file.rs internal: Replace Display impl for Name 2023-05-24 20:55:12 +02:00
move_to_mod_rs.rs internal: Replace Display impl for Name 2023-05-24 20:55:12 +02:00
number_representation.rs Migrate assists to format args captures, part 3 2022-10-12 02:28:41 -04:00
promote_local_to_const.rs Add flag to disallow opaque types for DisplayTarget::SourceCode 2023-04-12 19:03:48 +09:00
pull_assignment_up.rs Spelling 2023-04-19 09:45:55 -04:00
qualify_method_call.rs Spelling 2023-04-19 09:45:55 -04:00
qualify_path.rs internal: Replace Display impl for Name 2023-05-24 20:55:12 +02:00
raw_string.rs Support c string literals 2023-05-18 11:06:05 +02:00
remove_dbg.rs internal: Prioritize remove-dbg assist over inline-macro 2023-03-15 14:19:50 +01:00
remove_mut.rs Run cargo fix --edition-idioms 2022-07-20 15:02:08 +02:00
remove_parentheses.rs Spelling 2023-04-19 09:45:55 -04:00
remove_unused_param.rs Spelling 2023-04-19 09:45:55 -04:00
reorder_fields.rs internal: Replace Display impl for Name 2023-05-24 20:55:12 +02:00
reorder_impl_items.rs internal: Replace Display impl for Name 2023-05-24 20:55:12 +02:00
replace_arith_op.rs Fix replace_arith label 2023-01-17 16:31:34 +02:00
replace_derive_with_manual_impl.rs Option begone part 2 2023-04-16 19:20:48 +02:00
replace_if_let_with_match.rs Adjust replace_match_with_if_let applicability range 2023-03-05 16:52:07 +01:00
replace_let_with_if_let.rs Run cargo fix --edition-idioms 2022-07-20 15:02:08 +02:00
replace_method_eager_lazy.rs feature: Make replace_or_with_or_else assists more generally applicable 2023-03-06 22:17:30 +01:00
replace_named_generic_with_impl.rs Improve assist to filter invalid params 2023-06-02 12:46:01 +02:00
replace_qualified_name_with_use.rs Restructure find_path into a separate functions for modules and non-module items 2022-09-13 15:15:27 +02:00
replace_string_with_char.rs Spelling 2023-04-19 09:45:55 -04:00
replace_try_expr_with_match.rs desugar ? operator 2023-03-17 13:08:35 +03:30
replace_turbofish_with_explicit_type.rs Add flag to disallow opaque types for DisplayTarget::SourceCode 2023-04-12 19:03:48 +09:00
sort_items.rs Restrict "sort items" assist inside Impl & Trait 2023-04-17 12:36:32 +02:00
split_import.rs Run cargo fix --edition-idioms 2022-07-20 15:02:08 +02:00
toggle_ignore.rs Run cargo fix --edition-idioms 2022-07-20 15:02:08 +02:00
unmerge_match_arm.rs a number of code simplifications 2023-01-10 18:48:51 +00:00
unmerge_use.rs Fmt 2022-09-02 21:18:36 +00:00
unnecessary_async.rs remove needless borrows 2023-01-02 14:52:32 +00:00
unqualify_method_call.rs Rename assist: convert_ufcs_to_method => unqualify_method_call 2023-01-09 14:23:30 +00:00
unwrap_block.rs Simplify 2023-03-28 16:32:26 +02:00
unwrap_result_return_type.rs Address code review comments 2023-04-27 03:03:13 +01:00
unwrap_tuple.rs Migrate assists to format args captures, part 3 2022-10-12 02:28:41 -04:00
wrap_return_type_in_result.rs Migrate assists to format args captures, part 3 2022-10-12 02:28:41 -04:00