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(
2626) -> Option < ( ) > {
2727 let match_expr = ctx. find_node_at_offset :: < ast:: MatchExpr > ( ) ?;
2828 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 ( ) {
3033 cov_mark:: hit!( non_two_arm_match) ;
3134 return None ;
3235 }
33-
34- let first_arm = match_arm_list. arms ( ) . next ( ) ?;
3536 let first_arm_expr = first_arm. expr ( ) ;
3637
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
4040 } else if is_bool_literal_expr ( & first_arm_expr, false ) {
41- invert_matches = true ;
41+ true
4242 } else {
4343 cov_mark:: hit!( non_bool_literal_match) ;
4444 return None ;
45- }
45+ } ;
4646
4747 let target_range = ctx. sema . original_range ( match_expr. syntax ( ) ) . range ;
4848 let expr = match_expr. expr ( ) ?;
You can’t perform that action at this time.
0 commit comments