Skip to content

Commit cc6eee1

Browse files
committed
cosmetics
1 parent e25b20e commit cc6eee1

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

crates/ide_assists/src/handlers/add_missing_match_arms.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use hir::{Adt, HasSource, ModuleDef, Semantics};
55
use ide_db::helpers::{mod_path_to_ast, FamousDefs};
66
use ide_db::RootDatabase;
77
use itertools::Itertools;
8-
use syntax::ast::{self, AstNode, HasName, MatchArm, MatchArmList, MatchExpr, Pat, make};
8+
use syntax::ast::{self, make, AstNode, HasName, MatchArm, MatchArmList, MatchExpr, Pat};
99
use syntax::TextRange;
1010

1111
use crate::{
@@ -40,9 +40,9 @@ use crate::{
4040
pub(crate) fn add_missing_match_arms(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
4141
let match_expr = ctx.find_node_at_offset_with_descend::<ast::MatchExpr>()?;
4242
let match_arm_list = match_expr.match_arm_list()?;
43-
let target_range : TextRange;
43+
let target_range: TextRange;
4444

45-
if let None = trivial_match_arm_list_at_cursor(&ctx, &match_expr, &match_arm_list) {
45+
if let None = cursor_at_trivial_match_arm_list(&ctx, &match_expr, &match_arm_list) {
4646
target_range = TextRange::new(
4747
ctx.sema.original_range(match_expr.syntax()).range.start(),
4848
ctx.sema.original_range(match_arm_list.syntax()).range.start(),
@@ -52,8 +52,7 @@ pub(crate) fn add_missing_match_arms(acc: &mut Assists, ctx: &AssistContext) ->
5252
if !cursor_in_range {
5353
return None;
5454
}
55-
}
56-
else {
55+
} else {
5756
target_range = ctx.sema.original_range(match_expr.syntax()).range;
5857
}
5958

@@ -193,7 +192,11 @@ pub(crate) fn add_missing_match_arms(acc: &mut Assists, ctx: &AssistContext) ->
193192
)
194193
}
195194

196-
fn trivial_match_arm_list_at_cursor(ctx: &AssistContext, match_expr : &MatchExpr, match_arm_list : &MatchArmList) -> Option<()> {
195+
fn cursor_at_trivial_match_arm_list(
196+
ctx: &AssistContext,
197+
match_expr: &MatchExpr,
198+
match_arm_list: &MatchArmList,
199+
) -> Option<()> {
197200
// match x { $0 }
198201
if match_arm_list.arms().next() == None {
199202
return Some(());
@@ -204,7 +207,7 @@ fn trivial_match_arm_list_at_cursor(ctx: &AssistContext, match_expr : &MatchExpr
204207
let arm = wild_pat.syntax().parent().and_then(ast::MatchArm::cast)?;
205208
let arm_match_expr = arm.syntax().ancestors().nth(2).and_then(ast::MatchExpr::cast)?;
206209
if arm_match_expr == *match_expr {
207-
return Some(())
210+
return Some(());
208211
}
209212

210213
None
@@ -975,7 +978,6 @@ fn main() {
975978
);
976979
}
977980

978-
979981
#[test]
980982
fn wildcard_inside_expression_not_applicable() {
981983
check_assist_not_applicable(

0 commit comments

Comments
 (0)