From 0ed8ce096d3ae9ee4027ab4723958a021ef24194 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 19 Dec 2019 17:13:08 +0100 Subject: Touch up TokenSet a bit --- crates/ra_parser/src/grammar.rs | 2 +- crates/ra_parser/src/grammar/expressions/atom.rs | 2 +- crates/ra_parser/src/parser.rs | 2 +- crates/ra_parser/src/token_set.rs | 8 +++----- 4 files changed, 6 insertions(+), 8 deletions(-) (limited to 'crates/ra_parser') diff --git a/crates/ra_parser/src/grammar.rs b/crates/ra_parser/src/grammar.rs index 6e9e212b7..22f64a9f4 100644 --- a/crates/ra_parser/src/grammar.rs +++ b/crates/ra_parser/src/grammar.rs @@ -264,7 +264,7 @@ fn name_r(p: &mut Parser, recovery: TokenSet) { } fn name(p: &mut Parser) { - name_r(p, TokenSet::empty()) + name_r(p, TokenSet::EMPTY) } fn name_ref(p: &mut Parser) { diff --git a/crates/ra_parser/src/grammar/expressions/atom.rs b/crates/ra_parser/src/grammar/expressions/atom.rs index 6f5545a83..4ac1d6334 100644 --- a/crates/ra_parser/src/grammar/expressions/atom.rs +++ b/crates/ra_parser/src/grammar/expressions/atom.rs @@ -444,7 +444,7 @@ fn match_arm(p: &mut Parser) -> BlockLike { // } attributes::outer_attributes(p); - patterns::pattern_list_r(p, TokenSet::empty()); + patterns::pattern_list_r(p, TokenSet::EMPTY); if p.at(T![if]) { match_guard(p); } diff --git a/crates/ra_parser/src/parser.rs b/crates/ra_parser/src/parser.rs index dafd5247b..1071c46dc 100644 --- a/crates/ra_parser/src/parser.rs +++ b/crates/ra_parser/src/parser.rs @@ -208,7 +208,7 @@ impl<'t> Parser<'t> { /// Create an error node and consume the next token. pub(crate) fn err_and_bump(&mut self, message: &str) { - self.err_recover(message, TokenSet::empty()); + self.err_recover(message, TokenSet::EMPTY); } /// Create an error node and consume the next token. diff --git a/crates/ra_parser/src/token_set.rs b/crates/ra_parser/src/token_set.rs index 2a6952c01..994017acf 100644 --- a/crates/ra_parser/src/token_set.rs +++ b/crates/ra_parser/src/token_set.rs @@ -1,4 +1,4 @@ -//! FIXME: write short doc here +//! A bit-set of `SyntaxKind`s. use crate::SyntaxKind; @@ -7,9 +7,7 @@ use crate::SyntaxKind; pub(crate) struct TokenSet(u128); impl TokenSet { - pub(crate) const fn empty() -> TokenSet { - TokenSet(0) - } + pub(crate) const EMPTY: TokenSet = TokenSet(0); pub(crate) const fn singleton(kind: SyntaxKind) -> TokenSet { TokenSet(mask(kind)) @@ -30,7 +28,7 @@ const fn mask(kind: SyntaxKind) -> u128 { #[macro_export] macro_rules! token_set { - ($($t:expr),*) => { TokenSet::empty()$(.union(TokenSet::singleton($t)))* }; + ($($t:expr),*) => { TokenSet::EMPTY$(.union(TokenSet::singleton($t)))* }; ($($t:expr),* ,) => { token_set!($($t),*) }; } -- cgit v1.2.3