Unnamed repository; edit this file 'description' to name the repository.
internal: remove unused dollars
Aleksey Kladov 2021-10-24
parent 5a83d1b · commit 485c5e6
-rw-r--r--crates/parser/src/grammar/expressions/atom.rs28
-rw-r--r--crates/parser/src/grammar/types.rs1
-rw-r--r--crates/parser/src/parser.rs16
-rw-r--r--crates/parser/src/syntax_kind/generated.rs2
-rw-r--r--crates/syntax/src/tests/ast_src.rs11
5 files changed, 5 insertions, 53 deletions
diff --git a/crates/parser/src/grammar/expressions/atom.rs b/crates/parser/src/grammar/expressions/atom.rs
index 7075ae297f..640caa0778 100644
--- a/crates/parser/src/grammar/expressions/atom.rs
+++ b/crates/parser/src/grammar/expressions/atom.rs
@@ -39,7 +39,6 @@ pub(super) const ATOM_EXPR_FIRST: TokenSet =
T!['('],
T!['{'],
T!['['],
- L_DOLLAR,
T![|],
T![move],
T![box],
@@ -59,7 +58,7 @@ pub(super) const ATOM_EXPR_FIRST: TokenSet =
LIFETIME_IDENT,
]));
-const EXPR_RECOVERY_SET: TokenSet = TokenSet::new(&[T![let], R_DOLLAR]);
+const EXPR_RECOVERY_SET: TokenSet = TokenSet::new(&[T![let]]);
pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMarker, BlockLike)> {
if let Some(m) = literal(p) {
@@ -72,7 +71,6 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar
let done = match p.current() {
T!['('] => tuple_expr(p),
T!['['] => array_expr(p),
- L_DOLLAR => meta_var_expr(p),
T![|] => closure_expr(p),
T![move] if la == T![|] => closure_expr(p),
T![async] if la == T![|] || (la == T![move] && p.nth(2) == T![|]) => closure_expr(p),
@@ -622,27 +620,3 @@ fn box_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker {
}
m.complete(p, BOX_EXPR)
}
-
-/// Expression from `$var` macro expansion, wrapped in dollars
-fn meta_var_expr(p: &mut Parser) -> CompletedMarker {
- assert!(p.at(L_DOLLAR));
- let m = p.start();
- p.bump(L_DOLLAR);
- let expr = expr_bp(p, None, Restrictions { forbid_structs: false, prefer_stmt: false }, 1);
-
- match (expr, p.current()) {
- (Some((cm, _)), R_DOLLAR) => {
- p.bump(R_DOLLAR);
- // FIXME: this leaves the dollar hanging in the air...
- m.abandon(p);
- cm
- }
- _ => {
- while !p.at(R_DOLLAR) {
- p.bump_any();
- }
- p.bump(R_DOLLAR);
- m.complete(p, ERROR)
- }
- }
-}
diff --git a/crates/parser/src/grammar/types.rs b/crates/parser/src/grammar/types.rs
index 1a6fb651cb..05c1aea5c4 100644
--- a/crates/parser/src/grammar/types.rs
+++ b/crates/parser/src/grammar/types.rs
@@ -19,7 +19,6 @@ pub(super) const TYPE_FIRST: TokenSet = paths::PATH_FIRST.union(TokenSet::new(&[
const TYPE_RECOVERY_SET: TokenSet = TokenSet::new(&[
T![')'],
T![,],
- L_DOLLAR,
// test_err struct_field_recover
// struct S { f pub g: () }
T![pub],
diff --git a/crates/parser/src/parser.rs b/crates/parser/src/parser.rs
index 89dfea52f8..5820ffd77d 100644
--- a/crates/parser/src/parser.rs
+++ b/crates/parser/src/parser.rs
@@ -7,7 +7,7 @@ use drop_bomb::DropBomb;
use crate::{
event::Event,
ParseError,
- SyntaxKind::{self, EOF, ERROR, L_DOLLAR, R_DOLLAR, TOMBSTONE},
+ SyntaxKind::{self, EOF, ERROR, TOMBSTONE},
TokenSet, TokenSource, T,
};
@@ -215,23 +215,13 @@ impl<'t> Parser<'t> {
/// Create an error node and consume the next token.
pub(crate) fn err_and_bump(&mut self, message: &str) {
- match self.current() {
- L_DOLLAR | R_DOLLAR => {
- let m = self.start();
- self.error(message);
- self.bump_any();
- m.complete(self, ERROR);
- }
- _ => {
- self.err_recover(message, TokenSet::EMPTY);
- }
- }
+ self.err_recover(message, TokenSet::EMPTY);
}
/// Create an error node and consume the next token.
pub(crate) fn err_recover(&mut self, message: &str, recovery: TokenSet) {
match self.current() {
- T!['{'] | T!['}'] | L_DOLLAR | R_DOLLAR => {
+ T!['{'] | T!['}'] => {
self.error(message);
return;
}
diff --git a/crates/parser/src/syntax_kind/generated.rs b/crates/parser/src/syntax_kind/generated.rs
index a9010c0c31..99e7651906 100644
--- a/crates/parser/src/syntax_kind/generated.rs
+++ b/crates/parser/src/syntax_kind/generated.rs
@@ -120,8 +120,6 @@ pub enum SyntaxKind {
LIFETIME_IDENT,
COMMENT,
SHEBANG,
- L_DOLLAR,
- R_DOLLAR,
SOURCE_FILE,
STRUCT,
UNION,
diff --git a/crates/syntax/src/tests/ast_src.rs b/crates/syntax/src/tests/ast_src.rs
index 2344fc59d1..c0f1d5ef56 100644
--- a/crates/syntax/src/tests/ast_src.rs
+++ b/crates/syntax/src/tests/ast_src.rs
@@ -72,16 +72,7 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc {
],
contextual_keywords: &["auto", "default", "existential", "union", "raw", "macro_rules"],
literals: &["INT_NUMBER", "FLOAT_NUMBER", "CHAR", "BYTE", "STRING", "BYTE_STRING"],
- tokens: &[
- "ERROR",
- "IDENT",
- "WHITESPACE",
- "LIFETIME_IDENT",
- "COMMENT",
- "SHEBANG",
- "L_DOLLAR",
- "R_DOLLAR",
- ],
+ tokens: &["ERROR", "IDENT", "WHITESPACE", "LIFETIME_IDENT", "COMMENT", "SHEBANG"],
nodes: &[
"SOURCE_FILE",
"STRUCT",