File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed
crates/ide-assists/src/handlers Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -26,23 +26,23 @@ pub(crate) fn convert_two_arm_bool_match_to_matches_macro(
26
26
) -> Option < ( ) > {
27
27
let match_expr = ctx. find_node_at_offset :: < ast:: MatchExpr > ( ) ?;
28
28
let match_arm_list = match_expr. match_arm_list ( ) ?;
29
- if match_arm_list. arms ( ) . count ( ) != 2 {
29
+ let mut arms = match_arm_list. arms ( ) ;
30
+ let first_arm = arms. next ( ) ?;
31
+ let second_arm = arms. next ( ) ?;
32
+ if arms. next ( ) . is_some ( ) {
30
33
cov_mark:: hit!( non_two_arm_match) ;
31
34
return None ;
32
35
}
33
-
34
- let first_arm = match_arm_list. arms ( ) . next ( ) ?;
35
36
let first_arm_expr = first_arm. expr ( ) ;
36
37
37
- let invert_matches;
38
- if is_bool_literal_expr ( & first_arm_expr, true ) {
39
- invert_matches = false ;
38
+ let invert_matches = if is_bool_literal_expr ( & first_arm_expr, true ) {
39
+ false
40
40
} else if is_bool_literal_expr ( & first_arm_expr, false ) {
41
- invert_matches = true ;
41
+ true
42
42
} else {
43
43
cov_mark:: hit!( non_bool_literal_match) ;
44
44
return None ;
45
- }
45
+ } ;
46
46
47
47
let target_range = ctx. sema . original_range ( match_expr. syntax ( ) ) . range ;
48
48
let expr = match_expr. expr ( ) ?;
You can’t perform that action at this time.
0 commit comments