aboutsummaryrefslogtreecommitdiff
path: root/crates/syntax
diff options
context:
space:
mode:
Diffstat (limited to 'crates/syntax')
-rw-r--r--crates/syntax/Cargo.toml2
-rw-r--r--crates/syntax/src/ast/expr_ext.rs4
-rw-r--r--crates/syntax/src/ast/generated/nodes.rs33
-rw-r--r--crates/syntax/src/ast/make.rs8
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0138_self_param_outer_attr.rast20
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0154_no_dyn_trait_leading_for.rast43
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0154_no_dyn_trait_leading_for.rs1
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0154_tuple_attrs.rast50
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0154_tuple_attrs.rs1
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0156_const_block_pat.rast76
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0156_const_block_pat.rs4
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0157_const_block.rast23
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0157_const_block.rs1
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0158_macro_rules_non_brace.rast57
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0158_macro_rules_non_brace.rs2
-rw-r--r--crates/syntax/test_data/parser/ok/0051_parameter_attrs.rast222
-rw-r--r--crates/syntax/test_data/parser/ok/0063_variadic_fun.rast28
17 files changed, 437 insertions, 138 deletions
diff --git a/crates/syntax/Cargo.toml b/crates/syntax/Cargo.toml
index c6a6f11e1..21015591c 100644
--- a/crates/syntax/Cargo.toml
+++ b/crates/syntax/Cargo.toml
@@ -13,7 +13,7 @@ doctest = false
13[dependencies] 13[dependencies]
14itertools = "0.9.0" 14itertools = "0.9.0"
15rowan = "0.10.0" 15rowan = "0.10.0"
16rustc_lexer = { version = "691.0.0", package = "rustc-ap-rustc_lexer" } 16rustc_lexer = { version = "695.0.0", package = "rustc-ap-rustc_lexer" }
17rustc-hash = "1.1.0" 17rustc-hash = "1.1.0"
18arrayvec = "0.5.1" 18arrayvec = "0.5.1"
19once_cell = "1.3.1" 19once_cell = "1.3.1"
diff --git a/crates/syntax/src/ast/expr_ext.rs b/crates/syntax/src/ast/expr_ext.rs
index e4a9b945c..636ce166d 100644
--- a/crates/syntax/src/ast/expr_ext.rs
+++ b/crates/syntax/src/ast/expr_ext.rs
@@ -358,6 +358,7 @@ pub enum Effect {
358 Async(SyntaxToken), 358 Async(SyntaxToken),
359 Unsafe(SyntaxToken), 359 Unsafe(SyntaxToken),
360 Try(SyntaxToken), 360 Try(SyntaxToken),
361 Const(SyntaxToken),
361 // Very much not an effect, but we stuff it into this node anyway 362 // Very much not an effect, but we stuff it into this node anyway
362 Label(ast::Label), 363 Label(ast::Label),
363} 364}
@@ -373,6 +374,9 @@ impl ast::EffectExpr {
373 if let Some(token) = self.try_token() { 374 if let Some(token) = self.try_token() {
374 return Effect::Try(token); 375 return Effect::Try(token);
375 } 376 }
377 if let Some(token) = self.const_token() {
378 return Effect::Const(token);
379 }
376 if let Some(label) = self.label() { 380 if let Some(label) = self.label() {
377 return Effect::Label(label); 381 return Effect::Label(label);
378 } 382 }
diff --git a/crates/syntax/src/ast/generated/nodes.rs b/crates/syntax/src/ast/generated/nodes.rs
index 1588ba93e..c5b80bffe 100644
--- a/crates/syntax/src/ast/generated/nodes.rs
+++ b/crates/syntax/src/ast/generated/nodes.rs
@@ -763,6 +763,7 @@ impl EffectExpr {
763 pub fn try_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![try]) } 763 pub fn try_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![try]) }
764 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) } 764 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
765 pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) } 765 pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) }
766 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
766 pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) } 767 pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
767} 768}
768#[derive(Debug, Clone, PartialEq, Eq, Hash)] 769#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -1251,6 +1252,14 @@ impl TupleStructPat {
1251 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 1252 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
1252} 1253}
1253#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1254#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1255pub struct ConstBlockPat {
1256 pub(crate) syntax: SyntaxNode,
1257}
1258impl ConstBlockPat {
1259 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
1260 pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
1261}
1262#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1254pub struct RecordPatFieldList { 1263pub struct RecordPatFieldList {
1255 pub(crate) syntax: SyntaxNode, 1264 pub(crate) syntax: SyntaxNode,
1256} 1265}
@@ -1369,6 +1378,7 @@ pub enum Pat {
1369 SlicePat(SlicePat), 1378 SlicePat(SlicePat),
1370 TuplePat(TuplePat), 1379 TuplePat(TuplePat),
1371 TupleStructPat(TupleStructPat), 1380 TupleStructPat(TupleStructPat),
1381 ConstBlockPat(ConstBlockPat),
1372} 1382}
1373#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1383#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1374pub enum FieldList { 1384pub enum FieldList {
@@ -2772,6 +2782,17 @@ impl AstNode for TupleStructPat {
2772 } 2782 }
2773 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2783 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2774} 2784}
2785impl AstNode for ConstBlockPat {
2786 fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_BLOCK_PAT }
2787 fn cast(syntax: SyntaxNode) -> Option<Self> {
2788 if Self::can_cast(syntax.kind()) {
2789 Some(Self { syntax })
2790 } else {
2791 None
2792 }
2793 }
2794 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2795}
2775impl AstNode for RecordPatFieldList { 2796impl AstNode for RecordPatFieldList {
2776 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_PAT_FIELD_LIST } 2797 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_PAT_FIELD_LIST }
2777 fn cast(syntax: SyntaxNode) -> Option<Self> { 2798 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -3242,12 +3263,15 @@ impl From<TuplePat> for Pat {
3242impl From<TupleStructPat> for Pat { 3263impl From<TupleStructPat> for Pat {
3243 fn from(node: TupleStructPat) -> Pat { Pat::TupleStructPat(node) } 3264 fn from(node: TupleStructPat) -> Pat { Pat::TupleStructPat(node) }
3244} 3265}
3266impl From<ConstBlockPat> for Pat {
3267 fn from(node: ConstBlockPat) -> Pat { Pat::ConstBlockPat(node) }
3268}
3245impl AstNode for Pat { 3269impl AstNode for Pat {
3246 fn can_cast(kind: SyntaxKind) -> bool { 3270 fn can_cast(kind: SyntaxKind) -> bool {
3247 match kind { 3271 match kind {
3248 IDENT_PAT | BOX_PAT | REST_PAT | LITERAL_PAT | MACRO_PAT | OR_PAT | PAREN_PAT 3272 IDENT_PAT | BOX_PAT | REST_PAT | LITERAL_PAT | MACRO_PAT | OR_PAT | PAREN_PAT
3249 | PATH_PAT | WILDCARD_PAT | RANGE_PAT | RECORD_PAT | REF_PAT | SLICE_PAT 3273 | PATH_PAT | WILDCARD_PAT | RANGE_PAT | RECORD_PAT | REF_PAT | SLICE_PAT
3250 | TUPLE_PAT | TUPLE_STRUCT_PAT => true, 3274 | TUPLE_PAT | TUPLE_STRUCT_PAT | CONST_BLOCK_PAT => true,
3251 _ => false, 3275 _ => false,
3252 } 3276 }
3253 } 3277 }
@@ -3268,6 +3292,7 @@ impl AstNode for Pat {
3268 SLICE_PAT => Pat::SlicePat(SlicePat { syntax }), 3292 SLICE_PAT => Pat::SlicePat(SlicePat { syntax }),
3269 TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }), 3293 TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }),
3270 TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }), 3294 TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }),
3295 CONST_BLOCK_PAT => Pat::ConstBlockPat(ConstBlockPat { syntax }),
3271 _ => return None, 3296 _ => return None,
3272 }; 3297 };
3273 Some(res) 3298 Some(res)
@@ -3289,6 +3314,7 @@ impl AstNode for Pat {
3289 Pat::SlicePat(it) => &it.syntax, 3314 Pat::SlicePat(it) => &it.syntax,
3290 Pat::TuplePat(it) => &it.syntax, 3315 Pat::TuplePat(it) => &it.syntax,
3291 Pat::TupleStructPat(it) => &it.syntax, 3316 Pat::TupleStructPat(it) => &it.syntax,
3317 Pat::ConstBlockPat(it) => &it.syntax,
3292 } 3318 }
3293 } 3319 }
3294} 3320}
@@ -4137,6 +4163,11 @@ impl std::fmt::Display for TupleStructPat {
4137 std::fmt::Display::fmt(self.syntax(), f) 4163 std::fmt::Display::fmt(self.syntax(), f)
4138 } 4164 }
4139} 4165}
4166impl std::fmt::Display for ConstBlockPat {
4167 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4168 std::fmt::Display::fmt(self.syntax(), f)
4169 }
4170}
4140impl std::fmt::Display for RecordPatFieldList { 4171impl std::fmt::Display for RecordPatFieldList {
4141 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4172 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4142 std::fmt::Display::fmt(self.syntax(), f) 4173 std::fmt::Display::fmt(self.syntax(), f)
diff --git a/crates/syntax/src/ast/make.rs b/crates/syntax/src/ast/make.rs
index ba7e5d2fb..cafa4c198 100644
--- a/crates/syntax/src/ast/make.rs
+++ b/crates/syntax/src/ast/make.rs
@@ -4,6 +4,11 @@
4//! Note that all functions here intended to be stupid constructors, which just 4//! Note that all functions here intended to be stupid constructors, which just
5//! assemble a finish node from immediate children. If you want to do something 5//! assemble a finish node from immediate children. If you want to do something
6//! smarter than that, it probably doesn't belong in this module. 6//! smarter than that, it probably doesn't belong in this module.
7//!
8//! Keep in mind that `from_text` functions should be kept private. The public
9//! API should require to assemble every node piecewise. The trick of
10//! `parse(format!())` we use internally is an implementation detail -- long
11//! term, it will be replaced with direct tree manipulation.
7use itertools::Itertools; 12use itertools::Itertools;
8use stdx::format_to; 13use stdx::format_to;
9 14
@@ -16,7 +21,8 @@ pub fn name(text: &str) -> ast::Name {
16pub fn name_ref(text: &str) -> ast::NameRef { 21pub fn name_ref(text: &str) -> ast::NameRef {
17 ast_from_text(&format!("fn f() {{ {}; }}", text)) 22 ast_from_text(&format!("fn f() {{ {}; }}", text))
18} 23}
19 24// FIXME: replace stringly-typed constructor with a family of typed ctors, a-la
25// `expr_xxx`.
20pub fn ty(text: &str) -> ast::Type { 26pub fn ty(text: &str) -> ast::Type {
21 ast_from_text(&format!("impl {} for D {{}};", text)) 27 ast_from_text(&format!("impl {} for D {{}};", text))
22} 28}
diff --git a/crates/syntax/test_data/parser/inline/ok/0138_self_param_outer_attr.rast b/crates/syntax/test_data/parser/inline/ok/0138_self_param_outer_attr.rast
index 6403ff8d5..d3219f0b2 100644
--- a/crates/syntax/test_data/parser/inline/ok/0138_self_param_outer_attr.rast
+++ b/crates/syntax/test_data/parser/inline/ok/0138_self_param_outer_attr.rast
@@ -6,16 +6,16 @@ [email protected]
6 [email protected] "f" 6 [email protected] "f"
7 [email protected] 7 [email protected]
8 [email protected] "(" 8 [email protected] "("
9 ATT[email protected]6 9 SELF_PARAM@5..21
10 POUND@5..6 "#" 10 ATTR@5..16
11 L_BRACK@6..7 "[" 11 POUND@5..6 "#"
12 PATH@7..15 12 L_BRACK@6..7 "["
13 PATH_SEGMENT@7..15 13 [email protected]
14 NAME_REF@7..15 14 PATH_SEGMENT@7..15
15 IDENT@7..15 "must_use" 15 NAME_REF@7..15
16 R_BRACK@15..16 "]" 16 IDENT@7..15 "must_use"
17 WHITESPACE@16..17 " " 17 R_BRACK@15..16 "]"
18 SELF_PARAM@17..21 18 WHITESPACE@16..17 " "
19 [email protected] "self" 19 [email protected] "self"
20 [email protected] ")" 20 [email protected] ")"
21 [email protected] " " 21 [email protected] " "
diff --git a/crates/syntax/test_data/parser/inline/ok/0154_no_dyn_trait_leading_for.rast b/crates/syntax/test_data/parser/inline/ok/0154_no_dyn_trait_leading_for.rast
new file mode 100644
index 000000000..edfcb288c
--- /dev/null
+++ b/crates/syntax/test_data/parser/inline/ok/0154_no_dyn_trait_leading_for.rast
@@ -0,0 +1,43 @@
1[email protected]
2 [email protected]
3 [email protected] "type"
4 [email protected] " "
5 [email protected]
6 [email protected] "A"
7 [email protected] " "
8 [email protected] "="
9 [email protected] " "
10 [email protected]
11 [email protected]
12 [email protected]
13 [email protected]
14 [email protected] "for"
15 [email protected]
16 [email protected] "<"
17 [email protected]
18 [email protected]
19 [email protected] "\'a"
20 [email protected] ">"
21 [email protected] " "
22 [email protected]
23 [email protected]
24 [email protected]
25 [email protected]
26 [email protected] "Test"
27 [email protected]
28 [email protected] "<"
29 [email protected]
30 [email protected]
31 [email protected] "\'a"
32 [email protected] ">"
33 [email protected] " "
34 [email protected] "+"
35 [email protected] " "
36 [email protected]
37 [email protected]
38 [email protected]
39 [email protected]
40 [email protected]
41 [email protected] "Send"
42 [email protected] ";"
43 [email protected] "\n"
diff --git a/crates/syntax/test_data/parser/inline/ok/0154_no_dyn_trait_leading_for.rs b/crates/syntax/test_data/parser/inline/ok/0154_no_dyn_trait_leading_for.rs
new file mode 100644
index 000000000..47a71fd19
--- /dev/null
+++ b/crates/syntax/test_data/parser/inline/ok/0154_no_dyn_trait_leading_for.rs
@@ -0,0 +1 @@
type A = for<'a> Test<'a> + Send;
diff --git a/crates/syntax/test_data/parser/inline/ok/0154_tuple_attrs.rast b/crates/syntax/test_data/parser/inline/ok/0154_tuple_attrs.rast
new file mode 100644
index 000000000..d34b21abe
--- /dev/null
+++ b/crates/syntax/test_data/parser/inline/ok/0154_tuple_attrs.rast
@@ -0,0 +1,50 @@
1[email protected]
2 [email protected]
3 [email protected] "const"
4 [email protected] " "
5 [email protected]
6 [email protected] "A"
7 [email protected] ":"
8 [email protected] " "
9 [email protected]
10 [email protected] "("
11 [email protected]
12 [email protected]
13 [email protected]
14 [email protected]
15 [email protected] "i64"
16 [email protected] ","
17 [email protected] " "
18 [email protected]
19 [email protected]
20 [email protected]
21 [email protected]
22 [email protected] "i64"
23 [email protected] ")"
24 [email protected] " "
25 [email protected] "="
26 [email protected] " "
27 [email protected]
28 [email protected] "("
29 [email protected]
30 [email protected] "1"
31 [email protected] ","
32 [email protected] " "
33 [email protected]
34 [email protected]
35 [email protected] "#"
36 [email protected] "["
37 [email protected]
38 [email protected]
39 [email protected]
40 [email protected] "cfg"
41 [email protected]
42 [email protected] "("
43 [email protected] "test"
44 [email protected] ")"
45 [email protected] "]"
46 [email protected] " "
47 [email protected] "2"
48 [email protected] ")"
49 [email protected] ";"
50 [email protected] "\n"
diff --git a/crates/syntax/test_data/parser/inline/ok/0154_tuple_attrs.rs b/crates/syntax/test_data/parser/inline/ok/0154_tuple_attrs.rs
new file mode 100644
index 000000000..f84b7ab31
--- /dev/null
+++ b/crates/syntax/test_data/parser/inline/ok/0154_tuple_attrs.rs
@@ -0,0 +1 @@
const A: (i64, i64) = (1, #[cfg(test)] 2);
diff --git a/crates/syntax/test_data/parser/inline/ok/0156_const_block_pat.rast b/crates/syntax/test_data/parser/inline/ok/0156_const_block_pat.rast
new file mode 100644
index 000000000..8ff4822c4
--- /dev/null
+++ b/crates/syntax/test_data/parser/inline/ok/0156_const_block_pat.rast
@@ -0,0 +1,76 @@
1[email protected]
2 [email protected]
3 [email protected] "fn"
4 [email protected] " "
5 [email protected]
6 [email protected] "main"
7 [email protected]
8 [email protected] "("
9 [email protected] ")"
10 [email protected] " "
11 [email protected]
12 [email protected] "{"
13 [email protected] "\n "
14 [email protected]
15 [email protected] "let"
16 [email protected] " "
17 [email protected]
18 [email protected] "const"
19 [email protected] " "
20 [email protected]
21 [email protected] "{"
22 [email protected] " "
23 [email protected]
24 [email protected] "15"
25 [email protected] " "
26 [email protected] "}"
27 [email protected] " "
28 [email protected] "="
29 [email protected] " "
30 [email protected]
31 [email protected] "("
32 [email protected] ")"
33 [email protected] ";"
34 [email protected] "\n "
35 [email protected]
36 [email protected] "let"
37 [email protected] " "
38 [email protected]
39 [email protected] "const"
40 [email protected] " "
41 [email protected]
42 [email protected] "{"
43 [email protected] " "
44 [email protected]
45 [email protected]
46 [email protected]
47 [email protected]
48 [email protected]
49 [email protected]
50 [email protected] "foo"
51 [email protected]
52 [email protected] "("
53 [email protected] ")"
54 [email protected] ";"
55 [email protected] " "
56 [email protected]
57 [email protected]
58 [email protected]
59 [email protected]
60 [email protected]
61 [email protected] "bar"
62 [email protected]
63 [email protected] "("
64 [email protected] ")"
65 [email protected] " "
66 [email protected] "}"
67 [email protected] " "
68 [email protected] "="
69 [email protected] " "
70 [email protected]
71 [email protected] "("
72 [email protected] ")"
73 [email protected] ";"
74 [email protected] "\n"
75 [email protected] "}"
76 [email protected] "\n"
diff --git a/crates/syntax/test_data/parser/inline/ok/0156_const_block_pat.rs b/crates/syntax/test_data/parser/inline/ok/0156_const_block_pat.rs
new file mode 100644
index 000000000..dce9defac
--- /dev/null
+++ b/crates/syntax/test_data/parser/inline/ok/0156_const_block_pat.rs
@@ -0,0 +1,4 @@
1fn main() {
2 let const { 15 } = ();
3 let const { foo(); bar() } = ();
4}
diff --git a/crates/syntax/test_data/parser/inline/ok/0157_const_block.rast b/crates/syntax/test_data/parser/inline/ok/0157_const_block.rast
new file mode 100644
index 000000000..d5d2c8fe3
--- /dev/null
+++ b/crates/syntax/test_data/parser/inline/ok/0157_const_block.rast
@@ -0,0 +1,23 @@
1[email protected]
2 [email protected]
3 [email protected] "fn"
4 [email protected] " "
5 [email protected]
6 [email protected] "f"
7 [email protected]
8 [email protected] "("
9 [email protected] ")"
10 [email protected] " "
11 [email protected]
12 [email protected] "{"
13 [email protected] " "
14 [email protected]
15 [email protected] "const"
16 [email protected] " "
17 [email protected]
18 [email protected] "{"
19 [email protected] " "
20 [email protected] "}"
21 [email protected] " "
22 [email protected] "}"
23 [email protected] "\n"
diff --git a/crates/syntax/test_data/parser/inline/ok/0157_const_block.rs b/crates/syntax/test_data/parser/inline/ok/0157_const_block.rs
new file mode 100644
index 000000000..a2e3565a3
--- /dev/null
+++ b/crates/syntax/test_data/parser/inline/ok/0157_const_block.rs
@@ -0,0 +1 @@
fn f() { const { } }
diff --git a/crates/syntax/test_data/parser/inline/ok/0158_macro_rules_non_brace.rast b/crates/syntax/test_data/parser/inline/ok/0158_macro_rules_non_brace.rast
new file mode 100644
index 000000000..4a1f712aa
--- /dev/null
+++ b/crates/syntax/test_data/parser/inline/ok/0158_macro_rules_non_brace.rast
@@ -0,0 +1,57 @@
1[email protected]
2 [email protected]
3 [email protected] "macro_rules"
4 [email protected] "!"
5 [email protected] " "
6 [email protected]
7 [email protected] "m"
8 [email protected] " "
9 [email protected]
10 [email protected] "("
11 [email protected] " "
12 [email protected]
13 [email protected] "("
14 [email protected] "$"
15 [email protected] "i"
16 [email protected] ":"
17 [email protected] "ident"
18 [email protected] ")"
19 [email protected] " "
20 [email protected] "="
21 [email protected] ">"
22 [email protected] " "
23 [email protected]
24 [email protected] "{"
25 [email protected] "}"
26 [email protected] " "
27 [email protected] ")"
28 [email protected] ";"
29 [email protected] "\n"
30 [email protected]
31 [email protected] "macro_rules"
32 [email protected] "!"
33 [email protected] " "
34 [email protected]
35 [email protected] "m"
36 [email protected] " "
37 [email protected]
38 [email protected] "["
39 [email protected] " "
40 [email protected]
41 [email protected] "("
42 [email protected] "$"
43 [email protected] "i"
44 [email protected] ":"
45 [email protected] "ident"
46 [email protected] ")"
47 [email protected] " "
48 [email protected] "="
49 [email protected] ">"
50 [email protected] " "
51 [email protected]
52 [email protected] "{"
53 [email protected] "}"
54 [email protected] " "
55 [email protected] "]"
56 [email protected] ";"
57 [email protected] "\n"
diff --git a/crates/syntax/test_data/parser/inline/ok/0158_macro_rules_non_brace.rs b/crates/syntax/test_data/parser/inline/ok/0158_macro_rules_non_brace.rs
new file mode 100644
index 000000000..6033a28cd
--- /dev/null
+++ b/crates/syntax/test_data/parser/inline/ok/0158_macro_rules_non_brace.rs
@@ -0,0 +1,2 @@
1macro_rules! m ( ($i:ident) => {} );
2macro_rules! m [ ($i:ident) => {} ];
diff --git a/crates/syntax/test_data/parser/ok/0051_parameter_attrs.rast b/crates/syntax/test_data/parser/ok/0051_parameter_attrs.rast
index 8974f9e40..3fed11838 100644
--- a/crates/syntax/test_data/parser/ok/0051_parameter_attrs.rast
+++ b/crates/syntax/test_data/parser/ok/0051_parameter_attrs.rast
@@ -107,16 +107,16 @@ [email protected]
107 [email protected] "i8" 107 [email protected] "i8"
108 [email protected] "," 108 [email protected] ","
109 [email protected] " " 109 [email protected] " "
110 ATT[email protected]3 110 PARAM@106..117
111 POUND@106..107 "#" 111 ATTR@106..113
112 L_BRACK@107..108 "[" 112 POUND@106..107 "#"
113 PATH@108..112 113 L_BRACK@107..108 "["
114 PATH_SEGMENT@108..112 114 [email protected]
115 NAME_REF@108..112 115 PATH_SEGMENT@108..112
116 IDENT@108..112 "attr" 116 NAME_REF@108..112
117 R_BRACK@112..113 "]" 117 IDENT@108..112 "attr"
118 WHITESPACE@113..114 " " 118 R_BRACK@112..113 "]"
119 PARAM@114..117 119 WHITESPACE@113..114 " "
120 [email protected] "..." 120 [email protected] "..."
121 [email protected] ")" 121 [email protected] ")"
122 [email protected] " " 122 [email protected] " "
@@ -153,16 +153,16 @@ [email protected]
153 [email protected] "FnMut" 153 [email protected] "FnMut"
154 [email protected] 154 [email protected]
155 [email protected] "(" 155 [email protected] "("
156 ATT[email protected]53 156 PARAM@146..166
157 POUND@146..147 "#" 157 ATTR@146..153
158 L_BRACK@147..148 "[" 158 POUND@146..147 "#"
159 PATH@148..152 159 L_BRACK@147..148 "["
160 PATH_SEGMENT@148..152 160 [email protected]
161 NAME_REF@148..152 161 PATH_SEGMENT@148..152
162 IDENT@148..152 "attr" 162 NAME_REF@148..152
163 R_BRACK@152..153 "]" 163 IDENT@148..152 "attr"
164 WHITESPACE@153..154 " " 164 R_BRACK@152..153 "]"
165 PARAM@154..166 165 WHITESPACE@153..154 " "
166 [email protected] 166 [email protected]
167 [email protected] "&" 167 [email protected] "&"
168 [email protected] "mut" 168 [email protected] "mut"
@@ -224,17 +224,17 @@ [email protected]
224 [email protected] "u64" 224 [email protected] "u64"
225 [email protected] "," 225 [email protected] ","
226 [email protected] " " 226 [email protected] " "
227 ATT[email protected]1 227 PARAM@213..232
228 POUND@213..214 "#" 228 ATTR@213..221
229 WHITESPACE@214..215 " " 229 POUND@213..214 "#"
230 L_BRACK@215..216 "[" 230 WHITESPACE@214..215 " "
231 PATH@216..220 231 L_BRACK@215..216 "["
232 PATH_SEGMENT@216..220 232 [email protected]
233 NAME_REF@216..220 233 PATH_SEGMENT@216..220
234 IDENT@216..220 "attr" 234 NAME_REF@216..220
235 R_BRACK@220..221 "]" 235 IDENT@216..220 "attr"
236 WHITESPACE@221..222 " " 236 R_BRACK@220..221 "]"
237 PARAM@222..232 237 WHITESPACE@221..222 " "
238 [email protected] 238 [email protected]
239 [email protected] "mut" 239 [email protected] "mut"
240 [email protected] " " 240 [email protected] " "
@@ -271,16 +271,16 @@ [email protected]
271 [email protected] "f" 271 [email protected] "f"
272 [email protected] 272 [email protected]
273 [email protected] "(" 273 [email protected] "("
274 ATT[email protected]68 274 SELF_PARAM@257..273
275 POUND@257..258 "#" 275 ATTR@257..268
276 L_BRACK@258..259 "[" 276 POUND@257..258 "#"
277 PATH@259..267 277 L_BRACK@258..259 "["
278 PATH_SEGMENT@259..267 278 [email protected]
279 NAME_REF@259..267 279 PATH_SEGMENT@259..267
280 IDENT@259..267 "must_use" 280 NAME_REF@259..267
281 R_BRACK@267..268 "]" 281 IDENT@259..267 "must_use"
282 WHITESPACE@268..269 " " 282 R_BRACK@267..268 "]"
283 SELF_PARAM@269..273 283 WHITESPACE@268..269 " "
284 [email protected] "self" 284 [email protected] "self"
285 [email protected] ")" 285 [email protected] ")"
286 [email protected] " " 286 [email protected] " "
@@ -295,16 +295,16 @@ [email protected]
295 [email protected] "g1" 295 [email protected] "g1"
296 [email protected] 296 [email protected]
297 [email protected] "(" 297 [email protected] "("
298 ATTR@289..296 298 SELF_PARAM@289..301
299 POUND@289..290 "#" 299 ATTR@289..296
300 L_BRACK@290..291 "[" 300 POUND@289..290 "#"
301 PATH@291..295 301 L_BRACK@290..291 "["
302 PATH_SEGMENT@291..295 302 [email protected]
303 NAME_REF@291..295 303 PATH_SEGMENT@291..295
304 IDENT@291..295 "attr" 304 NAME_REF@291..295
305 R_BRACK@295..296 "]" 305 IDENT@291..295 "attr"
306 WHITESPACE@296..297 " " 306 R_BRACK@295..296 "]"
307 SELF_PARAM@297..301 307 WHITESPACE@296..297 " "
308 [email protected] "self" 308 [email protected] "self"
309 [email protected] ")" 309 [email protected] ")"
310 [email protected] " " 310 [email protected] " "
@@ -319,16 +319,16 @@ [email protected]
319 [email protected] "g2" 319 [email protected] "g2"
320 [email protected] 320 [email protected]
321 [email protected] "(" 321 [email protected] "("
322 ATT[email protected]24 322 SELF_PARAM@317..330
323 POUND@317..318 "#" 323 ATTR@317..324
324 L_BRACK@318..319 "[" 324 POUND@317..318 "#"
325 PATH@319..323 325 L_BRACK@318..319 "["
326 PATH_SEGMENT@319..323 326 [email protected]
327 NAME_REF@319..323 327 PATH_SEGMENT@319..323
328 IDENT@319..323 "attr" 328 NAME_REF@319..323
329 R_BRACK@323..324 "]" 329 IDENT@319..323 "attr"
330 WHITESPACE@324..325 " " 330 R_BRACK@323..324 "]"
331 SELF_PARAM@325..330 331 WHITESPACE@324..325 " "
332 [email protected] "&" 332 [email protected] "&"
333 [email protected] "self" 333 [email protected] "self"
334 [email protected] ")" 334 [email protected] ")"
@@ -350,16 +350,16 @@ [email protected]
350 [email protected] ">" 350 [email protected] ">"
351 [email protected] 351 [email protected]
352 [email protected] "(" 352 [email protected] "("
353 ATT[email protected]57 353 SELF_PARAM@350..367
354 POUND@350..351 "#" 354 ATTR@350..357
355 L_BRACK@351..352 "[" 355 POUND@350..351 "#"
356 PATH@352..356 356 L_BRACK@351..352 "["
357 PATH_SEGMENT@352..356 357 [email protected]
358 NAME_REF@352..356 358 PATH_SEGMENT@352..356
359 IDENT@352..356 "attr" 359 NAME_REF@352..356
360 R_BRACK@356..357 "]" 360 IDENT@352..356 "attr"
361 WHITESPACE@357..358 " " 361 R_BRACK@356..357 "]"
362 SELF_PARAM@358..367 362 WHITESPACE@357..358 " "
363 [email protected] "&" 363 [email protected] "&"
364 [email protected] "mut" 364 [email protected] "mut"
365 [email protected] " " 365 [email protected] " "
@@ -383,16 +383,16 @@ [email protected]
383 [email protected] ">" 383 [email protected] ">"
384 [email protected] 384 [email protected]
385 [email protected] "(" 385 [email protected] "("
386 ATTR@387..394 386 SELF_PARAM@387..403
387 POUND@387..388 "#" 387 ATTR@387..394
388 L_BRACK@388..389 "[" 388 POUND@387..388 "#"
389 PATH@389..393 389 L_BRACK@388..389 "["
390 PATH_SEGMENT@389..393 390 [email protected]
391 NAME_REF@389..393 391 PATH_SEGMENT@389..393
392 IDENT@389..393 "attr" 392 NAME_REF@389..393
393 R_BRACK@393..394 "]" 393 IDENT@389..393 "attr"
394 WHITESPACE@394..395 " " 394 R_BRACK@393..394 "]"
395 SELF_PARAM@395..403 395 WHITESPACE@394..395 " "
396 [email protected] "&" 396 [email protected] "&"
397 [email protected] 397 [email protected]
398 [email protected] "\'a" 398 [email protected] "\'a"
@@ -417,16 +417,16 @@ [email protected]
417 [email protected] ">" 417 [email protected] ">"
418 [email protected] 418 [email protected]
419 [email protected] "(" 419 [email protected] "("
420 ATT[email protected]0 420 SELF_PARAM@423..443
421 POUND@423..424 "#" 421 ATTR@423..430
422 L_BRACK@424..425 "[" 422 POUND@423..424 "#"
423 PATH@425..429 423 L_BRACK@424..425 "["
424 PATH_SEGMENT@425..429 424 [email protected]
425 NAME_REF@425..429 425 PATH_SEGMENT@425..429
426 IDENT@425..429 "attr" 426 NAME_REF@425..429
427 R_BRACK@429..430 "]" 427 IDENT@425..429 "attr"
428 WHITESPACE@430..431 " " 428 R_BRACK@429..430 "]"
429 SELF_PARAM@431..443 429 WHITESPACE@430..431 " "
430 [email protected] "&" 430 [email protected] "&"
431 [email protected] 431 [email protected]
432 [email protected] "\'a" 432 [email protected] "\'a"
@@ -447,16 +447,16 @@ [email protected]
447 [email protected] "c" 447 [email protected] "c"
448 [email protected] 448 [email protected]
449 [email protected] "(" 449 [email protected] "("
450 ATT[email protected]5 450 SELF_PARAM@458..476
451 POUND@458..459 "#" 451 ATTR@458..465
452 L_BRACK@459..460 "[" 452 POUND@458..459 "#"
453 PATH@460..464 453 L_BRACK@459..460 "["
454 PATH_SEGMENT@460..464 454 [email protected]
455 NAME_REF@460..464 455 PATH_SEGMENT@460..464
456 IDENT@460..464 "attr" 456 NAME_REF@460..464
457 R_BRACK@464..465 "]" 457 IDENT@460..464 "attr"
458 WHITESPACE@465..466 " " 458 R_BRACK@464..465 "]"
459 SELF_PARAM@466..476 459 WHITESPACE@465..466 " "
460 [email protected] "self" 460 [email protected] "self"
461 [email protected] ":" 461 [email protected] ":"
462 [email protected] " " 462 [email protected] " "
@@ -478,16 +478,16 @@ [email protected]
478 [email protected] "d" 478 [email protected] "d"
479 [email protected] 479 [email protected]
480 [email protected] "(" 480 [email protected] "("
481 ATTR@491..498 481 SELF_PARAM@491..513
482 POUND@491..492 "#" 482 ATTR@491..498
483 L_BRACK@492..493 "[" 483 POUND@491..492 "#"
484 PATH@493..497 484 L_BRACK@492..493 "["
485 PATH_SEGMENT@493..497 485 [email protected]
486 NAME_REF@493..497 486 PATH_SEGMENT@493..497
487 IDENT@493..497 "attr" 487 NAME_REF@493..497
488 R_BRACK@497..498 "]" 488 IDENT@493..497 "attr"
489 WHITESPACE@498..499 " " 489 R_BRACK@497..498 "]"
490 SELF_PARAM@499..513 490 WHITESPACE@498..499 " "
491 [email protected] "self" 491 [email protected] "self"
492 [email protected] ":" 492 [email protected] ":"
493 [email protected] " " 493 [email protected] " "
diff --git a/crates/syntax/test_data/parser/ok/0063_variadic_fun.rast b/crates/syntax/test_data/parser/ok/0063_variadic_fun.rast
index 4009b3ff8..f7c094898 100644
--- a/crates/syntax/test_data/parser/ok/0063_variadic_fun.rast
+++ b/crates/syntax/test_data/parser/ok/0063_variadic_fun.rast
@@ -92,20 +92,20 @@ [email protected]
92 [email protected] "u8" 92 [email protected] "u8"
93 [email protected] "," 93 [email protected] ","
94 [email protected] " " 94 [email protected] " "
95 ATT[email protected]5 95 PARAM@92..120
96 POUND@92..93 "#" 96 ATTR@92..105
97 L_BRACK@93..94 "[" 97 POUND@92..93 "#"
98 PATH@94..97 98 L_BRACK@93..94 "["
99 PATH_SEGMENT@94..97 99 [email protected]
100 NAME_REF@94..97 100 PATH_SEGMENT@94..97
101 IDENT@94..97 "cfg" 101 NAME_REF@94..97
102 TOKEN_TREE@97..104 102 IDENT@94..97 "cfg"
103 L_PAREN@97..98 "(" 103 TOKEN_TREE@97..104
104 IDENT@98..103 "never" 104 L_PAREN@97..98 "("
105 R_PAREN@103..104 ")" 105 IDENT@98..103 "never"
106 R_BRACK@104..105 "]" 106 R_PAREN@103..104 ")"
107 WHITESPACE@105..106 " " 107 R_BRACK@104..105 "]"
108 PARAM@106..120 108 WHITESPACE@105..106 " "
109 [email protected] 109 [email protected]
110 [email protected] "[" 110 [email protected] "["
111 [email protected] 111 [email protected]