From 7910202ecdd28654b01c0c039b00c01edff42916 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 9 Sep 2019 13:23:37 +0300 Subject: tiny simplification --- crates/ra_parser/src/grammar.rs | 2 +- crates/ra_parser/src/grammar/attributes.rs | 2 +- crates/ra_parser/src/grammar/expressions.rs | 4 ++-- crates/ra_parser/src/grammar/type_params.rs | 5 ++++- 4 files changed, 8 insertions(+), 5 deletions(-) (limited to 'crates') diff --git a/crates/ra_parser/src/grammar.rs b/crates/ra_parser/src/grammar.rs index be9419e0c..a2ad580bc 100644 --- a/crates/ra_parser/src/grammar.rs +++ b/crates/ra_parser/src/grammar.rs @@ -125,7 +125,7 @@ pub(crate) mod fragments { let m = p.start(); while !p.at(EOF) { - if p.current() == T![;] { + if p.at(T![;]) { p.bump(); continue; } diff --git a/crates/ra_parser/src/grammar/attributes.rs b/crates/ra_parser/src/grammar/attributes.rs index 20d58445f..e97170203 100644 --- a/crates/ra_parser/src/grammar/attributes.rs +++ b/crates/ra_parser/src/grammar/attributes.rs @@ -1,7 +1,7 @@ use super::*; pub(super) fn inner_attributes(p: &mut Parser) { - while p.current() == T![#] && p.nth(1) == T![!] { + while p.at(T![#]) && p.nth(1) == T![!] { attribute(p, true) } } diff --git a/crates/ra_parser/src/grammar/expressions.rs b/crates/ra_parser/src/grammar/expressions.rs index ba8386d11..855418f1c 100644 --- a/crates/ra_parser/src/grammar/expressions.rs +++ b/crates/ra_parser/src/grammar/expressions.rs @@ -197,7 +197,7 @@ pub(crate) fn expr_block_contents(p: &mut Parser) { // struct S {}; // } - if p.current() == T![;] { + if p.at(T![;]) { p.bump(); continue; } @@ -302,7 +302,7 @@ fn expr_bp( newly_dollar_open = false; } - let is_range = p.current() == T![..] || p.current() == T![..=]; + let is_range = p.at(T![..]) || p.at(T![..=]); let (op_bp, op) = current_op(p); if op_bp < bp { break; diff --git a/crates/ra_parser/src/grammar/type_params.rs b/crates/ra_parser/src/grammar/type_params.rs index d739df727..cf54344c6 100644 --- a/crates/ra_parser/src/grammar/type_params.rs +++ b/crates/ra_parser/src/grammar/type_params.rs @@ -156,7 +156,10 @@ fn is_where_predicate(p: &mut Parser) -> bool { } fn is_where_clause_end(p: &mut Parser) -> bool { - p.current() == T!['{'] || p.current() == T![;] || p.current() == T![=] + match p.current() { + T!['{'] | T![;] | T![=] => true, + _ => false, + } } fn where_predicate(p: &mut Parser) { -- cgit v1.2.3