From e75e2ae5b6b6b1364368ceb3d4081b6508b2f001 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sun, 28 Jun 2020 04:02:03 +0300 Subject: Simlify with matches!() --- crates/ra_parser/src/grammar.rs | 5 +---- crates/ra_parser/src/grammar/paths.rs | 5 +---- crates/ra_parser/src/grammar/type_params.rs | 5 +---- crates/ra_parser/src/syntax_kind.rs | 5 +---- 4 files changed, 4 insertions(+), 16 deletions(-) (limited to 'crates/ra_parser/src') diff --git a/crates/ra_parser/src/grammar.rs b/crates/ra_parser/src/grammar.rs index 293baecf6..caedeead0 100644 --- a/crates/ra_parser/src/grammar.rs +++ b/crates/ra_parser/src/grammar.rs @@ -73,10 +73,7 @@ pub(crate) mod fragments { // Parse a meta item , which excluded [], e.g : #[ MetaItem ] pub(crate) fn meta_item(p: &mut Parser) { fn is_delimiter(p: &mut Parser) -> bool { - match p.current() { - T!['{'] | T!['('] | T!['['] => true, - _ => false, - } + matches!(p.current(), T!['{'] | T!['('] | T!['[']) } if is_delimiter(p) { diff --git a/crates/ra_parser/src/grammar/paths.rs b/crates/ra_parser/src/grammar/paths.rs index fd51189d5..b503af1dc 100644 --- a/crates/ra_parser/src/grammar/paths.rs +++ b/crates/ra_parser/src/grammar/paths.rs @@ -41,10 +41,7 @@ fn path(p: &mut Parser, mode: Mode) { path_segment(p, mode, true); let mut qual = path.complete(p, PATH); loop { - let use_tree = match p.nth(2) { - T![*] | T!['{'] => true, - _ => false, - }; + let use_tree = matches!(p.nth(2), T![*] | T!['{']); if p.at(T![::]) && !use_tree { let path = qual.precede(p); p.bump(T![::]); diff --git a/crates/ra_parser/src/grammar/type_params.rs b/crates/ra_parser/src/grammar/type_params.rs index 325d566ad..d1330d4b9 100644 --- a/crates/ra_parser/src/grammar/type_params.rs +++ b/crates/ra_parser/src/grammar/type_params.rs @@ -169,10 +169,7 @@ fn is_where_predicate(p: &mut Parser) -> bool { } fn is_where_clause_end(p: &mut Parser) -> bool { - match p.current() { - T!['{'] | T![;] | T![=] => true, - _ => false, - } + matches!(p.current(), T!['{'] | T![;] | T![=]) } fn where_predicate(p: &mut Parser) { diff --git a/crates/ra_parser/src/syntax_kind.rs b/crates/ra_parser/src/syntax_kind.rs index 8d6bd057b..63204436c 100644 --- a/crates/ra_parser/src/syntax_kind.rs +++ b/crates/ra_parser/src/syntax_kind.rs @@ -20,9 +20,6 @@ impl From for u16 { impl SyntaxKind { pub fn is_trivia(self) -> bool { - match self { - SyntaxKind::WHITESPACE | SyntaxKind::COMMENT => true, - _ => false, - } + matches!(self, SyntaxKind::WHITESPACE | SyntaxKind::COMMENT) } } -- cgit v1.2.3