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/src/ast | |
parent | 513924a7e01ef81a03869249c902daf148439736 (diff) |
Simlify with matches!()
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r-- | crates/ra_syntax/src/ast/expr_extensions.rs | 5 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/extensions.rs | 16 |
2 files changed, 9 insertions, 12 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 | } |