diff options
author | Veetaha <[email protected]> | 2020-06-28 02:02:03 +0100 |
---|---|---|
committer | Veetaha <[email protected]> | 2020-06-28 02:03:59 +0100 |
commit | e75e2ae5b6b6b1364368ceb3d4081b6508b2f001 (patch) | |
tree | e88a9920a908bfdf66c156ab582ce90d77d55c2f /crates/ra_syntax | |
parent | 513924a7e01ef81a03869249c902daf148439736 (diff) |
Simlify with matches!()
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r-- | crates/ra_syntax/src/ast/expr_extensions.rs | 5 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/extensions.rs | 16 | ||||
-rw-r--r-- | crates/ra_syntax/src/parsing/reparsing.rs | 5 |
3 files changed, 10 insertions, 16 deletions
diff --git a/crates/ra_syntax/src/ast/expr_extensions.rs b/crates/ra_syntax/src/ast/expr_extensions.rs index 7771d6759..db5438d68 100644 --- a/crates/ra_syntax/src/ast/expr_extensions.rs +++ b/crates/ra_syntax/src/ast/expr_extensions.rs | |||
@@ -399,10 +399,7 @@ impl ast::BlockExpr { | |||
399 | Some(it) => it, | 399 | Some(it) => it, |
400 | None => return true, | 400 | None => return true, |
401 | }; | 401 | }; |
402 | match parent.kind() { | 402 | !matches!(parent.kind(), FN_DEF | IF_EXPR | WHILE_EXPR | LOOP_EXPR | EFFECT_EXPR) |
403 | FN_DEF | IF_EXPR | WHILE_EXPR | LOOP_EXPR | EFFECT_EXPR => false, | ||
404 | _ => true, | ||
405 | } | ||
406 | } | 403 | } |
407 | } | 404 | } |
408 | 405 | ||
diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs index 98c38d009..662c6f73e 100644 --- a/crates/ra_syntax/src/ast/extensions.rs +++ b/crates/ra_syntax/src/ast/extensions.rs | |||
@@ -459,16 +459,16 @@ impl ast::RangePat { | |||
459 | 459 | ||
460 | impl ast::TokenTree { | 460 | impl ast::TokenTree { |
461 | pub fn left_delimiter_token(&self) -> Option<SyntaxToken> { | 461 | pub fn left_delimiter_token(&self) -> Option<SyntaxToken> { |
462 | self.syntax().first_child_or_token()?.into_token().filter(|it| match it.kind() { | 462 | self.syntax() |
463 | T!['{'] | T!['('] | T!['['] => true, | 463 | .first_child_or_token()? |
464 | _ => false, | 464 | .into_token() |
465 | }) | 465 | .filter(|it| matches!(it.kind(), T!['{'] | T!['('] | T!['['])) |
466 | } | 466 | } |
467 | 467 | ||
468 | pub fn right_delimiter_token(&self) -> Option<SyntaxToken> { | 468 | pub fn right_delimiter_token(&self) -> Option<SyntaxToken> { |
469 | self.syntax().last_child_or_token()?.into_token().filter(|it| match it.kind() { | 469 | self.syntax() |
470 | T!['}'] | T![')'] | T![']'] => true, | 470 | .last_child_or_token()? |
471 | _ => false, | 471 | .into_token() |
472 | }) | 472 | .filter(|it| matches!(it.kind(), T!['}'] | T![')'] | T![']'])) |
473 | } | 473 | } |
474 | } | 474 | } |
diff --git a/crates/ra_syntax/src/parsing/reparsing.rs b/crates/ra_syntax/src/parsing/reparsing.rs index edbc190f8..ed5a42ea3 100644 --- a/crates/ra_syntax/src/parsing/reparsing.rs +++ b/crates/ra_syntax/src/parsing/reparsing.rs | |||
@@ -120,10 +120,7 @@ fn get_text_after_edit(element: SyntaxElement, edit: &Indel) -> String { | |||
120 | } | 120 | } |
121 | 121 | ||
122 | fn is_contextual_kw(text: &str) -> bool { | 122 | fn is_contextual_kw(text: &str) -> bool { |
123 | match text { | 123 | matches!(text, "auto" | "default" | "union") |
124 | "auto" | "default" | "union" => true, | ||
125 | _ => false, | ||
126 | } | ||
127 | } | 124 | } |
128 | 125 | ||
129 | fn find_reparsable_node(node: &SyntaxNode, range: TextRange) -> Option<(SyntaxNode, Reparser)> { | 126 | fn find_reparsable_node(node: &SyntaxNode, range: TextRange) -> Option<(SyntaxNode, Reparser)> { |