rust-analyzer/crates/ide_assists/src/handlers
bors[bot] 4ec6bd6206
Merge #11017
11017: Support "move if to guard" with an else branch r=Veykril a=weirane

Support the assist `move_arm_cond_to_match_guard` when there is an else branch.

I have two questions:
1. How to indent the first line of a match arm? `matcharm.indent()` doesn't seem to work. so I hard coded four spaces here:
95a0de85d5/crates/ide_assists/src/handlers/move_guard.rs (L162-L163)

2. I find a little issue in the original implementation, this code
```rust
let y = match 92 {
    x => {
        if x == 0 {$0
            false
        }
    }
    _ => true,
};
```
will be transformed to
```rust
let y = match 92 {
    x if x == 0 => false
    _ => true,
};
```
a comma is missing after the `false`. Should I also fix that? Or this can go in a separate PR.

Closes #10997.

Co-authored-by: Wang Ruochen <wrc@ruo-chen.wang>
2021-12-15 23:04:51 +00:00
..
add_explicit_type.rs Remove inherent methods from ast node that carry semantic meaning 2021-09-26 16:49:03 +02:00
add_lifetime_to_type.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
add_missing_impl_members.rs fix: insert whitespaces into assoc items for assist when macro generated 2021-12-13 16:35:32 +01:00
add_missing_match_arms.rs adjust test case and stop deleting newline 2021-11-14 20:56:28 +09:00
add_return_type.rs refactor(assist/add_return_type): avoid threading needs_whitespace 2021-12-02 10:46:07 -08:00
add_turbo_fish.rs internal: Flatten Definition::ModuleDef variant 2021-11-11 00:05:53 +01:00
apply_demorgan.rs Make selections in assists with trailing/leading whitespace more forgiving 2021-10-12 14:41:59 +02:00
auto_import.rs Add Semantics::original_ast_node for upmapping nodes out of macro files 2021-11-03 21:12:36 +01:00
change_visibility.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
convert_bool_then.rs Parenthesize expressions in if_to_bool_then assist where required 2021-10-01 12:19:01 +02:00
convert_comment_block.rs internal: prevent possible bugs when adding magical comments 2021-09-13 13:43:13 +03:00
convert_integer_literal.rs 7526: Rename crate assists to ide_assists. 2021-02-23 00:59:16 +05:30
convert_into_to_from.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
convert_iter_for_each_to_for.rs Move ws insert rendering for macro expansion into ide_db 2021-12-13 15:55:13 +01:00
convert_to_guarded_return.rs internal: more reasonable grammar for blocks 2021-09-26 19:16:09 +03:00
convert_tuple_struct_to_named_struct.rs internal: Flatten Definition::ModuleDef variant 2021-11-11 00:05:53 +01:00
convert_while_to_loop.rs fix: defer condition construction 2021-12-04 04:50:06 +09:00
destructure_tuple_binding.rs Make AssistContext::frange private 2021-10-13 14:39:37 +02:00
expand_glob_import.rs internal: Flatten Definition::ModuleDef variant 2021-11-11 00:05:53 +01:00
extract_function.rs Bump deps 2021-12-07 13:15:14 +02:00
extract_module.rs internal: Flatten Definition::ModuleDef variant 2021-11-11 00:05:53 +01:00
extract_struct_from_enum_variant.rs internal: Flatten Definition::ModuleDef variant 2021-11-11 00:05:53 +01:00
extract_type_alias.rs Make AssistContext::frange private 2021-10-13 14:39:37 +02:00
extract_variable.rs fix: fix extract_variable not working on macro_call 2021-10-25 21:46:44 +02:00
fix_visibility.rs internal: Flatten Definition::ModuleDef variant 2021-11-11 00:05:53 +01:00
flip_binexpr.rs Make selections in assists with trailing/leading whitespace more forgiving 2021-10-12 14:41:59 +02:00
flip_comma.rs internal: don't use #[should_panic] for tests 2021-04-13 12:21:59 +03:00
flip_trait_bound.rs Upgrade rowan 2021-03-16 16:10:49 +03:00
generate_constant.rs cleanup 2021-10-06 10:14:12 +08:00
generate_default_from_enum_variant.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
generate_default_from_new.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
generate_delegate_methods.rs minor: fixup generate assist priorities 2021-12-13 16:42:21 +01:00
generate_deref.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
generate_derive.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
generate_documentation_template.rs feat: remove should_panic example generation 2021-12-11 22:46:54 +01:00
generate_enum_is_method.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
generate_enum_projection_method.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
generate_from_impl_for_enum.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
generate_function.rs internal: Flatten Definition::ModuleDef variant 2021-11-11 00:05:53 +01:00
generate_getter.rs Fixes 2021-10-20 21:35:35 +02:00
generate_impl.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
generate_is_empty_from_len.rs Move ws insert rendering for macro expansion into ide_db 2021-12-13 15:55:13 +01:00
generate_new.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
generate_setter.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
inline_call.rs fix: check inline left of binary_expression 2021-11-21 01:48:04 +09:00
inline_local_variable.rs Make AssistContext::frange private 2021-10-13 14:39:37 +02:00
introduce_named_generic.rs Rename some assists 2021-09-21 00:54:09 +02:00
introduce_named_lifetime.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
invert_if.rs Make selections in assists with trailing/leading whitespace more forgiving 2021-10-12 14:41:59 +02:00
merge_imports.rs Use mutable syntax trees in merge_imports, split_imports 2021-11-19 20:02:27 +05:00
merge_match_arms.rs Fix assists assuming comma belonging to MATCH_ARM_LIST 2021-07-30 16:01:26 +02:00
move_bounds.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
move_from_mod_rs.rs Make AssistContext::frange private 2021-10-13 14:39:37 +02:00
move_guard.rs Add coverage marks 2021-12-15 14:44:47 -08:00
move_module_to_file.rs Make AssistContext::frange private 2021-10-13 14:39:37 +02:00
move_to_mod_rs.rs Make AssistContext::frange private 2021-10-13 14:39:37 +02:00
number_representation.rs Reuse results from split_into_parts() 2021-12-13 21:16:04 +03:00
promote_local_to_const.rs Implement promotoe_local_to_const assist 2021-10-14 21:49:46 +02:00
pull_assignment_up.rs Replace if let with match where appropriate 2021-10-05 09:00:21 +11:00
qualify_method_call.rs apply code review suggestions 2021-10-21 23:42:14 -07:00
qualify_path.rs Enable auto-import and qualify-path in derive attributes 2021-10-28 18:40:38 +02:00
raw_string.rs Implement promotoe_local_to_const assist 2021-10-14 21:49:46 +02:00
remove_dbg.rs internal: more reasonable grammar for blocks 2021-09-26 19:16:09 +03:00
remove_mut.rs 7526: Rename crate assists to ide_assists. 2021-02-23 00:59:16 +05:30
remove_unused_param.rs internal: Flatten Definition::ModuleDef variant 2021-11-11 00:05:53 +01:00
reorder_fields.rs Allow several samples in "// Assist:" comments. 2021-08-02 19:49:36 +03:00
reorder_impl.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
replace_derive_with_manual_impl.rs Merge #11000 2021-12-13 15:43:12 +00:00
replace_if_let_with_match.rs Merge #10491 2021-10-14 22:41:06 +00:00
replace_let_with_if_let.rs Expose HasSource::source through Semantics with caching behaviour 2021-10-07 15:00:14 +02:00
replace_qualified_name_with_use.rs match_ast! takes a pattern to allow underscore usage 2021-12-14 12:44:31 +01:00
replace_string_with_char.rs Add replace_char_with_string assist 2021-07-30 16:46:06 +02:00
replace_try_expr_with_match.rs Use array IntoIter 2021-10-22 09:23:29 +03:00
replace_turbofish_with_explicit_type.rs fixup! rustfmt 2021-10-27 10:58:31 -07:00
sort_items.rs Make AssistContext::frange private 2021-10-13 14:39:37 +02:00
split_import.rs Use mutable syntax trees in merge_imports, split_imports 2021-11-19 20:02:27 +05:00
toggle_ignore.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
unmerge_use.rs Bump deps 2021-12-07 13:15:14 +02:00
unwrap_block.rs internal: more reasonable grammar for blocks 2021-09-26 19:16:09 +03:00
unwrap_result_return_type.rs fix(assist): delete trailing whitespaces 2021-10-19 14:54:29 +02:00
wrap_return_type_in_result.rs Remove inherent methods from ast node that carry semantic meaning 2021-09-26 16:49:03 +02:00