aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_assists')
-rw-r--r--crates/ra_assists/src/fill_match_arms.rs31
1 files changed, 14 insertions, 17 deletions
diff --git a/crates/ra_assists/src/fill_match_arms.rs b/crates/ra_assists/src/fill_match_arms.rs
index d51010b84..deef166b5 100644
--- a/crates/ra_assists/src/fill_match_arms.rs
+++ b/crates/ra_assists/src/fill_match_arms.rs
@@ -23,27 +23,24 @@ pub(crate) fn fill_match_arms(mut ctx: AssistCtx<impl HirDatabase>) -> Option<As
23 // We already have some match arms, so we don't provide any assists. 23 // We already have some match arms, so we don't provide any assists.
24 // Unless if there is only one trivial match arm possibly created 24 // Unless if there is only one trivial match arm possibly created
25 // by match postfix complete. Trivial match arm is the catch all arm. 25 // by match postfix complete. Trivial match arm is the catch all arm.
26 match match_expr.match_arm_list() { 26 if let Some(arm_list) = match_expr.match_arm_list() {
27 Some(arm_list) => { 27 let mut arm_iter = arm_list.arms();
28 let mut arm_iter = arm_list.arms(); 28 let first = arm_iter.next();
29 let first = arm_iter.next(); 29
30 30 match first {
31 match first { 31 // If there arm list is empty or there is only one trivial arm, then proceed.
32 // If there arm list is empty or there is only one trivial arm, then proceed. 32 Some(arm) if is_trivial_arm(arm) => {
33 Some(arm) if is_trivial_arm(arm) => { 33 if arm_iter.next() != None {
34 if arm_iter.next() != None {
35 return None;
36 }
37 }
38 None => {}
39
40 _ => {
41 return None; 34 return None;
42 } 35 }
43 } 36 }
37 None => {}
38
39 _ => {
40 return None;
41 }
44 } 42 }
45 _ => {} 43 };
46 }
47 44
48 let expr = match_expr.expr()?; 45 let expr = match_expr.expr()?;
49 let analyzer = hir::SourceAnalyzer::new(ctx.db, ctx.frange.file_id, expr.syntax(), None); 46 let analyzer = hir::SourceAnalyzer::new(ctx.db, ctx.frange.file_id, expr.syntax(), None);