2598: Touch up TokenSet a bit r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2019-12-19 16:15:19 +00:00 committed by GitHub
commit f00904e996
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 8 deletions

View 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) {

View 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);
}

View file

@ -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.

View file

@ -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),*) };
}