]> git.lizzy.rs Git - rust.git/commitdiff
Touch up TokenSet a bit
authorAleksey Kladov <aleksey.kladov@gmail.com>
Thu, 19 Dec 2019 16:13:08 +0000 (17:13 +0100)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Thu, 19 Dec 2019 16:13:33 +0000 (17:13 +0100)
crates/ra_parser/src/grammar.rs
crates/ra_parser/src/grammar/expressions/atom.rs
crates/ra_parser/src/parser.rs
crates/ra_parser/src/token_set.rs

index 6e9e212b76f341036f0acb1f2072dc2a5485251d..22f64a9f4addede1a7219dec317424be281552fa 100644 (file)
@@ -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) {
index 6f5545a83a6ac0521183778927abb064131043a7..4ac1d6334a0e64447c61ca9651b68ae1d4af7c3c 100644 (file)
@@ -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);
     }
index dafd5247bfce1ebd172ab1f8e3c1ba231211ffef..1071c46dc8eb00006b59f3d1a71e9bc65aae15e0 100644 (file)
@@ -208,7 +208,7 @@ pub(crate) fn expect(&mut self, kind: SyntaxKind) -> bool {
 
     /// 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.
index 2a6952c013ac8bc27d082ff6732c64bb0e9f65c9..994017acfd4409b2912313a9fb5cda9e3eb45ae6 100644 (file)
@@ -1,4 +1,4 @@
-//! FIXME: write short doc here
+//! A bit-set of `SyntaxKind`s.
 
 use crate::SyntaxKind;
 
@@ -7,9 +7,7 @@
 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),*) };
 }