diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-12-19 16:15:19 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-12-19 16:15:19 +0000 |
commit | f00904e996e9bc59749fb0d2696a711e9b881ae3 (patch) | |
tree | 69341c02cf6de6238102bef32014c11839fce289 /crates/ra_parser/src | |
parent | aee2eee3626020cbfa338d94f5371b0d3c8d82e3 (diff) | |
parent | 0ed8ce096d3ae9ee4027ab4723958a021ef24194 (diff) |
Merge #2598
2598: Touch up TokenSet a bit r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_parser/src')
-rw-r--r-- | crates/ra_parser/src/grammar.rs | 2 | ||||
-rw-r--r-- | crates/ra_parser/src/grammar/expressions/atom.rs | 2 | ||||
-rw-r--r-- | crates/ra_parser/src/parser.rs | 2 | ||||
-rw-r--r-- | crates/ra_parser/src/token_set.rs | 8 |
4 files changed, 6 insertions, 8 deletions
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) { | |||
264 | } | 264 | } |
265 | 265 | ||
266 | fn name(p: &mut Parser) { | 266 | fn name(p: &mut Parser) { |
267 | name_r(p, TokenSet::empty()) | 267 | name_r(p, TokenSet::EMPTY) |
268 | } | 268 | } |
269 | 269 | ||
270 | fn name_ref(p: &mut Parser) { | 270 | 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 { | |||
444 | // } | 444 | // } |
445 | attributes::outer_attributes(p); | 445 | attributes::outer_attributes(p); |
446 | 446 | ||
447 | patterns::pattern_list_r(p, TokenSet::empty()); | 447 | patterns::pattern_list_r(p, TokenSet::EMPTY); |
448 | if p.at(T![if]) { | 448 | if p.at(T![if]) { |
449 | match_guard(p); | 449 | match_guard(p); |
450 | } | 450 | } |
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> { | |||
208 | 208 | ||
209 | /// Create an error node and consume the next token. | 209 | /// Create an error node and consume the next token. |
210 | pub(crate) fn err_and_bump(&mut self, message: &str) { | 210 | pub(crate) fn err_and_bump(&mut self, message: &str) { |
211 | self.err_recover(message, TokenSet::empty()); | 211 | self.err_recover(message, TokenSet::EMPTY); |
212 | } | 212 | } |
213 | 213 | ||
214 | /// Create an error node and consume the next token. | 214 | /// 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 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! A bit-set of `SyntaxKind`s. |
2 | 2 | ||
3 | use crate::SyntaxKind; | 3 | use crate::SyntaxKind; |
4 | 4 | ||
@@ -7,9 +7,7 @@ use crate::SyntaxKind; | |||
7 | pub(crate) struct TokenSet(u128); | 7 | pub(crate) struct TokenSet(u128); |
8 | 8 | ||
9 | impl TokenSet { | 9 | impl TokenSet { |
10 | pub(crate) const fn empty() -> TokenSet { | 10 | pub(crate) const EMPTY: TokenSet = TokenSet(0); |
11 | TokenSet(0) | ||
12 | } | ||
13 | 11 | ||
14 | pub(crate) const fn singleton(kind: SyntaxKind) -> TokenSet { | 12 | pub(crate) const fn singleton(kind: SyntaxKind) -> TokenSet { |
15 | TokenSet(mask(kind)) | 13 | TokenSet(mask(kind)) |
@@ -30,7 +28,7 @@ const fn mask(kind: SyntaxKind) -> u128 { | |||
30 | 28 | ||
31 | #[macro_export] | 29 | #[macro_export] |
32 | macro_rules! token_set { | 30 | macro_rules! token_set { |
33 | ($($t:expr),*) => { TokenSet::empty()$(.union(TokenSet::singleton($t)))* }; | 31 | ($($t:expr),*) => { TokenSet::EMPTY$(.union(TokenSet::singleton($t)))* }; |
34 | ($($t:expr),* ,) => { token_set!($($t),*) }; | 32 | ($($t:expr),* ,) => { token_set!($($t),*) }; |
35 | } | 33 | } |
36 | 34 | ||