aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/release.yaml68
-rw-r--r--crates/parser/src/grammar.rs4
-rw-r--r--crates/parser/src/lib.rs2
-rw-r--r--crates/ssr/src/parsing.rs1
-rw-r--r--crates/ssr/src/tests.rs44
-rw-r--r--crates/syntax/src/lib.rs7
-rw-r--r--crates/syntax/src/tests.rs9
-rw-r--r--crates/syntax/test_data/parser/fragments/stmt/err/0000_attr.rast1
-rw-r--r--crates/syntax/test_data/parser/fragments/stmt/err/0000_attr.rs1
-rw-r--r--crates/syntax/test_data/parser/fragments/stmt/err/0000_multiple_stmts.rast1
-rw-r--r--crates/syntax/test_data/parser/fragments/stmt/err/0000_multiple_stmts.rs1
-rw-r--r--crates/syntax/test_data/parser/fragments/stmt/err/0000_open_parenthesis.rast1
-rw-r--r--crates/syntax/test_data/parser/fragments/stmt/err/0000_open_parenthesis.rs1
-rw-r--r--crates/syntax/test_data/parser/fragments/stmt/err/0000_semicolon.rast1
-rw-r--r--crates/syntax/test_data/parser/fragments/stmt/err/0000_semicolon.rs1
-rw-r--r--crates/syntax/test_data/parser/fragments/stmt/err/0000_unterminated_expr.rast1
-rw-r--r--crates/syntax/test_data/parser/fragments/stmt/err/0000_unterminated_expr.rs1
-rw-r--r--crates/syntax/test_data/parser/fragments/stmt/ok/0000_expr.rast9
-rw-r--r--crates/syntax/test_data/parser/fragments/stmt/ok/0000_expr.rs1
-rw-r--r--crates/syntax/test_data/parser/fragments/stmt/ok/0000_expr_block.rast69
-rw-r--r--crates/syntax/test_data/parser/fragments/stmt/ok/0000_expr_block.rs5
-rw-r--r--crates/syntax/test_data/parser/fragments/stmt/ok/0000_fn_call.rast11
-rw-r--r--crates/syntax/test_data/parser/fragments/stmt/ok/0000_fn_call.rs1
-rw-r--r--crates/syntax/test_data/parser/fragments/stmt/ok/0000_let_stmt.rast12
-rw-r--r--crates/syntax/test_data/parser/fragments/stmt/ok/0000_let_stmt.rs1
-rw-r--r--crates/syntax/test_data/parser/fragments/stmt/ok/0000_macro_let_stmt.rast21
-rw-r--r--crates/syntax/test_data/parser/fragments/stmt/ok/0000_macro_let_stmt.rs1
-rw-r--r--crates/syntax/test_data/parser/fragments/stmt/ok/0000_macro_unterminated_let_stmt.rast21
-rw-r--r--crates/syntax/test_data/parser/fragments/stmt/ok/0000_macro_unterminated_let_stmt.rs1
-rw-r--r--crates/syntax/test_data/parser/fragments/stmt/ok/0000_struct_item.rast22
-rw-r--r--crates/syntax/test_data/parser/fragments/stmt/ok/0000_struct_item.rs3
-rw-r--r--crates/syntax/test_data/parser/fragments/stmt/ok/0000_unterminated_fn_call.rast10
-rw-r--r--crates/syntax/test_data/parser/fragments/stmt/ok/0000_unterminated_fn_call.rs1
-rw-r--r--crates/syntax/test_data/parser/fragments/stmt/ok/0000_unterminated_let_stmt.rast11
-rw-r--r--crates/syntax/test_data/parser/fragments/stmt/ok/0000_unterminated_let_stmt.rs1
35 files changed, 329 insertions, 17 deletions
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
index 889ada401..cc39943ab 100644
--- a/.github/workflows/release.yaml
+++ b/.github/workflows/release.yaml
@@ -15,8 +15,8 @@ env:
15 RUSTUP_MAX_RETRIES: 10 15 RUSTUP_MAX_RETRIES: 10
16 16
17jobs: 17jobs:
18 dist-windows: 18 dist-x86_64-pc-windows-msvc:
19 name: dist (Windows) 19 name: dist (x86_64-pc-windows-msvc)
20 runs-on: windows-latest 20 runs-on: windows-latest
21 env: 21 env:
22 RA_TARGET: x86_64-pc-windows-msvc 22 RA_TARGET: x86_64-pc-windows-msvc
@@ -45,11 +45,41 @@ jobs:
45 - name: Upload artifacts 45 - name: Upload artifacts
46 uses: actions/upload-artifact@v1 46 uses: actions/upload-artifact@v1
47 with: 47 with:
48 name: dist-windows-latest 48 name: x86_64-pc-windows-msvc
49 path: ./dist 49 path: ./dist
50 50
51 dist-ubuntu: 51 dist-aarch64-pc-windows-msvc:
52 name: dist (Ubuntu 16.04) 52 name: dist (aarch64-pc-windows-msvc)
53 runs-on: windows-latest
54 env:
55 RA_TARGET: aarch64-pc-windows-msvc
56
57 steps:
58 - name: Checkout repository
59 uses: actions/checkout@v2
60
61 - name: Rename existing rust toolchain
62 run: Rename-Item C:\Users\runneradmin\.rustup\toolchains\stable-x86_64-pc-windows-msvc C:\Users\runneradmin\.rustup\toolchains\stable-x86_64-pc-windows-msvc.old
63
64 - name: Install Rust toolchain
65 uses: actions-rs/toolchain@v1
66 with:
67 toolchain: stable
68 target: aarch64-pc-windows-msvc
69 profile: minimal
70 override: true
71
72 - name: Dist
73 run: cargo xtask dist
74
75 - name: Upload artifacts
76 uses: actions/upload-artifact@v1
77 with:
78 name: dist-aarch64-pc-windows-msvc
79 path: ./dist
80
81 dist-x86_64-unknown-linux-gnu:
82 name: dist (x86_64-unknown-linux-gnu)
53 runs-on: ubuntu-16.04 83 runs-on: ubuntu-16.04
54 env: 84 env:
55 RA_TARGET: x86_64-unknown-linux-gnu 85 RA_TARGET: x86_64-unknown-linux-gnu
@@ -85,11 +115,11 @@ jobs:
85 - name: Upload artifacts 115 - name: Upload artifacts
86 uses: actions/upload-artifact@v1 116 uses: actions/upload-artifact@v1
87 with: 117 with:
88 name: dist-ubuntu-16.04 118 name: dist-x86_64-unknown-linux-gnu
89 path: ./dist 119 path: ./dist
90 120
91 dist-macos-latest: 121 dist-x86_64-apple-darwin:
92 name: dist (MacOS latest) 122 name: dist (x86_64-apple-darwin)
93 runs-on: macos-latest 123 runs-on: macos-latest
94 env: 124 env:
95 RA_TARGET: x86_64-apple-darwin 125 RA_TARGET: x86_64-apple-darwin
@@ -111,11 +141,11 @@ jobs:
111 - name: Upload artifacts 141 - name: Upload artifacts
112 uses: actions/upload-artifact@v1 142 uses: actions/upload-artifact@v1
113 with: 143 with:
114 name: dist-macos-latest 144 name: dist-x86_64-apple-darwin
115 path: ./dist 145 path: ./dist
116 146
117 dist-macos-11: 147 dist-aarch64-apple-darwin:
118 name: dist (MacOS 11.0) 148 name: dist (aarch64-apple-darwin)
119 runs-on: macos-11.0 149 runs-on: macos-11.0
120 env: 150 env:
121 RA_TARGET: aarch64-apple-darwin 151 RA_TARGET: aarch64-apple-darwin
@@ -138,13 +168,13 @@ jobs:
138 - name: Upload artifacts 168 - name: Upload artifacts
139 uses: actions/upload-artifact@v1 169 uses: actions/upload-artifact@v1
140 with: 170 with:
141 name: dist-macos-11.0 171 name: dist-aarch64-apple-darwin
142 path: ./dist 172 path: ./dist
143 173
144 publish: 174 publish:
145 name: publish 175 name: publish
146 runs-on: ubuntu-16.04 176 runs-on: ubuntu-16.04
147 needs: ['dist-windows', 'dist-ubuntu', 'dist-macos-latest', 'dist-macos-11'] 177 needs: ['dist-x86_64-pc-windows-msvc', 'dist-aarch64-pc-windows-msvc', 'dist-x86_64-unknown-linux-gnu', 'dist-x86_64-apple-darwin', 'dist-aarch64-apple-darwin']
148 steps: 178 steps:
149 - name: Install Nodejs 179 - name: Install Nodejs
150 uses: actions/setup-node@v1 180 uses: actions/setup-node@v1
@@ -165,19 +195,23 @@ jobs:
165 195
166 - uses: actions/download-artifact@v1 196 - uses: actions/download-artifact@v1
167 with: 197 with:
168 name: dist-macos-11.0 198 name: dist-aarch64-apple-darwin
199 path: dist
200 - uses: actions/download-artifact@v1
201 with:
202 name: dist-x86_64-apple-darwin
169 path: dist 203 path: dist
170 - uses: actions/download-artifact@v1 204 - uses: actions/download-artifact@v1
171 with: 205 with:
172 name: dist-macos-latest 206 name: dist-x86_64-unknown-linux-gnu
173 path: dist 207 path: dist
174 - uses: actions/download-artifact@v1 208 - uses: actions/download-artifact@v1
175 with: 209 with:
176 name: dist-ubuntu-16.04 210 name: dist-x86_64-pc-windows-msvc
177 path: dist 211 path: dist
178 - uses: actions/download-artifact@v1 212 - uses: actions/download-artifact@v1
179 with: 213 with:
180 name: dist-windows-latest 214 name: dist-aarch64-pc-windows-msvc
181 path: dist 215 path: dist
182 - run: ls -al ./dist 216 - run: ls -al ./dist
183 217
diff --git a/crates/parser/src/grammar.rs b/crates/parser/src/grammar.rs
index 63cc90027..bb9ffea8b 100644
--- a/crates/parser/src/grammar.rs
+++ b/crates/parser/src/grammar.rs
@@ -66,6 +66,10 @@ pub(crate) mod fragments {
66 expressions::stmt(p, expressions::StmtWithSemi::No) 66 expressions::stmt(p, expressions::StmtWithSemi::No)
67 } 67 }
68 68
69 pub(crate) fn stmt_optional_semi(p: &mut Parser) {
70 expressions::stmt(p, expressions::StmtWithSemi::Optional)
71 }
72
69 pub(crate) fn opt_visibility(p: &mut Parser) { 73 pub(crate) fn opt_visibility(p: &mut Parser) {
70 let _ = super::opt_visibility(p); 74 let _ = super::opt_visibility(p);
71 } 75 }
diff --git a/crates/parser/src/lib.rs b/crates/parser/src/lib.rs
index 811e740f9..9dfe63028 100644
--- a/crates/parser/src/lib.rs
+++ b/crates/parser/src/lib.rs
@@ -88,6 +88,7 @@ pub enum FragmentKind {
88 Path, 88 Path,
89 Expr, 89 Expr,
90 Statement, 90 Statement,
91 StatementOptionalSemi,
91 Type, 92 Type,
92 Pattern, 93 Pattern,
93 Item, 94 Item,
@@ -118,6 +119,7 @@ pub fn parse_fragment(
118 FragmentKind::Visibility => grammar::fragments::opt_visibility, 119 FragmentKind::Visibility => grammar::fragments::opt_visibility,
119 FragmentKind::MetaItem => grammar::fragments::meta_item, 120 FragmentKind::MetaItem => grammar::fragments::meta_item,
120 FragmentKind::Statement => grammar::fragments::stmt, 121 FragmentKind::Statement => grammar::fragments::stmt,
122 FragmentKind::StatementOptionalSemi => grammar::fragments::stmt_optional_semi,
121 FragmentKind::Items => grammar::fragments::macro_items, 123 FragmentKind::Items => grammar::fragments::macro_items,
122 FragmentKind::Statements => grammar::fragments::macro_stmts, 124 FragmentKind::Statements => grammar::fragments::macro_stmts,
123 FragmentKind::Attr => grammar::fragments::attr, 125 FragmentKind::Attr => grammar::fragments::attr,
diff --git a/crates/ssr/src/parsing.rs b/crates/ssr/src/parsing.rs
index f3b084baf..289affe90 100644
--- a/crates/ssr/src/parsing.rs
+++ b/crates/ssr/src/parsing.rs
@@ -78,6 +78,7 @@ impl ParsedRule {
78 builder.try_add(ast::Item::parse(&raw_pattern), raw_template.map(ast::Item::parse)); 78 builder.try_add(ast::Item::parse(&raw_pattern), raw_template.map(ast::Item::parse));
79 builder.try_add(ast::Path::parse(&raw_pattern), raw_template.map(ast::Path::parse)); 79 builder.try_add(ast::Path::parse(&raw_pattern), raw_template.map(ast::Path::parse));
80 builder.try_add(ast::Pat::parse(&raw_pattern), raw_template.map(ast::Pat::parse)); 80 builder.try_add(ast::Pat::parse(&raw_pattern), raw_template.map(ast::Pat::parse));
81 builder.try_add(ast::Stmt::parse(&raw_pattern), raw_template.map(ast::Stmt::parse));
81 builder.build() 82 builder.build()
82 } 83 }
83} 84}
diff --git a/crates/ssr/src/tests.rs b/crates/ssr/src/tests.rs
index 63131f6ca..c4149a849 100644
--- a/crates/ssr/src/tests.rs
+++ b/crates/ssr/src/tests.rs
@@ -160,6 +160,50 @@ fn assert_match_failure_reason(pattern: &str, code: &str, snippet: &str, expecte
160} 160}
161 161
162#[test] 162#[test]
163fn ssr_let_stmt_in_macro_match() {
164 assert_matches(
165 "let a = 0",
166 r#"
167 macro_rules! m1 { ($a:stmt) => {$a}; }
168 fn f() {m1!{ let a = 0 };}"#,
169 // FIXME: Whitespace is not part of the matched block
170 &["leta=0"],
171 );
172}
173
174#[test]
175fn ssr_let_stmt_in_fn_match() {
176 assert_matches("let $a = 10;", "fn main() { let x = 10; x }", &["let x = 10;"]);
177 assert_matches("let $a = $b;", "fn main() { let x = 10; x }", &["let x = 10;"]);
178}
179
180#[test]
181fn ssr_block_expr_match() {
182 assert_matches("{ let $a = $b; }", "fn main() { let x = 10; }", &["{ let x = 10; }"]);
183 assert_matches("{ let $a = $b; $c }", "fn main() { let x = 10; x }", &["{ let x = 10; x }"]);
184}
185
186#[test]
187fn ssr_let_stmt_replace() {
188 // Pattern and template with trailing semicolon
189 assert_ssr_transform(
190 "let $a = $b; ==>> let $a = 11;",
191 "fn main() { let x = 10; x }",
192 expect![["fn main() { let x = 11; x }"]],
193 );
194}
195
196#[test]
197fn ssr_let_stmt_replace_expr() {
198 // Trailing semicolon should be dropped from the new expression
199 assert_ssr_transform(
200 "let $a = $b; ==>> $b",
201 "fn main() { let x = 10; }",
202 expect![["fn main() { 10 }"]],
203 );
204}
205
206#[test]
163fn ssr_function_to_method() { 207fn ssr_function_to_method() {
164 assert_ssr_transform( 208 assert_ssr_transform(
165 "my_function($a, $b) ==>> ($a).my_method($b)", 209 "my_function($a, $b) ==>> ($a).my_method($b)",
diff --git a/crates/syntax/src/lib.rs b/crates/syntax/src/lib.rs
index 4d272f367..da151e328 100644
--- a/crates/syntax/src/lib.rs
+++ b/crates/syntax/src/lib.rs
@@ -212,6 +212,13 @@ impl ast::Attr {
212 } 212 }
213} 213}
214 214
215impl ast::Stmt {
216 /// Returns `text`, parsed as statement, but only if it has no errors.
217 pub fn parse(text: &str) -> Result<Self, ()> {
218 parsing::parse_text_fragment(text, parser::FragmentKind::StatementOptionalSemi)
219 }
220}
221
215/// Matches a `SyntaxNode` against an `ast` type. 222/// Matches a `SyntaxNode` against an `ast` type.
216/// 223///
217/// # Example: 224/// # Example:
diff --git a/crates/syntax/src/tests.rs b/crates/syntax/src/tests.rs
index 8c217dfe0..9d3433c9d 100644
--- a/crates/syntax/src/tests.rs
+++ b/crates/syntax/src/tests.rs
@@ -103,6 +103,15 @@ fn type_parser_tests() {
103} 103}
104 104
105#[test] 105#[test]
106fn stmt_parser_tests() {
107 fragment_parser_dir_test(
108 &["parser/fragments/stmt/ok"],
109 &["parser/fragments/stmt/err"],
110 crate::ast::Stmt::parse,
111 );
112}
113
114#[test]
106fn parser_fuzz_tests() { 115fn parser_fuzz_tests() {
107 for (_, text) in collect_rust_files(&test_data_dir(), &["parser/fuzz-failures"]) { 116 for (_, text) in collect_rust_files(&test_data_dir(), &["parser/fuzz-failures"]) {
108 fuzz::check_parser(&text) 117 fuzz::check_parser(&text)
diff --git a/crates/syntax/test_data/parser/fragments/stmt/err/0000_attr.rast b/crates/syntax/test_data/parser/fragments/stmt/err/0000_attr.rast
new file mode 100644
index 000000000..5df7507e2
--- /dev/null
+++ b/crates/syntax/test_data/parser/fragments/stmt/err/0000_attr.rast
@@ -0,0 +1 @@
ERROR
diff --git a/crates/syntax/test_data/parser/fragments/stmt/err/0000_attr.rs b/crates/syntax/test_data/parser/fragments/stmt/err/0000_attr.rs
new file mode 100644
index 000000000..988df0705
--- /dev/null
+++ b/crates/syntax/test_data/parser/fragments/stmt/err/0000_attr.rs
@@ -0,0 +1 @@
#[foo]
diff --git a/crates/syntax/test_data/parser/fragments/stmt/err/0000_multiple_stmts.rast b/crates/syntax/test_data/parser/fragments/stmt/err/0000_multiple_stmts.rast
new file mode 100644
index 000000000..5df7507e2
--- /dev/null
+++ b/crates/syntax/test_data/parser/fragments/stmt/err/0000_multiple_stmts.rast
@@ -0,0 +1 @@
ERROR
diff --git a/crates/syntax/test_data/parser/fragments/stmt/err/0000_multiple_stmts.rs b/crates/syntax/test_data/parser/fragments/stmt/err/0000_multiple_stmts.rs
new file mode 100644
index 000000000..7e3b2fd49
--- /dev/null
+++ b/crates/syntax/test_data/parser/fragments/stmt/err/0000_multiple_stmts.rs
@@ -0,0 +1 @@
a(); b(); c()
diff --git a/crates/syntax/test_data/parser/fragments/stmt/err/0000_open_parenthesis.rast b/crates/syntax/test_data/parser/fragments/stmt/err/0000_open_parenthesis.rast
new file mode 100644
index 000000000..5df7507e2
--- /dev/null
+++ b/crates/syntax/test_data/parser/fragments/stmt/err/0000_open_parenthesis.rast
@@ -0,0 +1 @@
ERROR
diff --git a/crates/syntax/test_data/parser/fragments/stmt/err/0000_open_parenthesis.rs b/crates/syntax/test_data/parser/fragments/stmt/err/0000_open_parenthesis.rs
new file mode 100644
index 000000000..2d06f3766
--- /dev/null
+++ b/crates/syntax/test_data/parser/fragments/stmt/err/0000_open_parenthesis.rs
@@ -0,0 +1 @@
(
diff --git a/crates/syntax/test_data/parser/fragments/stmt/err/0000_semicolon.rast b/crates/syntax/test_data/parser/fragments/stmt/err/0000_semicolon.rast
new file mode 100644
index 000000000..5df7507e2
--- /dev/null
+++ b/crates/syntax/test_data/parser/fragments/stmt/err/0000_semicolon.rast
@@ -0,0 +1 @@
ERROR
diff --git a/crates/syntax/test_data/parser/fragments/stmt/err/0000_semicolon.rs b/crates/syntax/test_data/parser/fragments/stmt/err/0000_semicolon.rs
new file mode 100644
index 000000000..092bc2b04
--- /dev/null
+++ b/crates/syntax/test_data/parser/fragments/stmt/err/0000_semicolon.rs
@@ -0,0 +1 @@
;
diff --git a/crates/syntax/test_data/parser/fragments/stmt/err/0000_unterminated_expr.rast b/crates/syntax/test_data/parser/fragments/stmt/err/0000_unterminated_expr.rast
new file mode 100644
index 000000000..5df7507e2
--- /dev/null
+++ b/crates/syntax/test_data/parser/fragments/stmt/err/0000_unterminated_expr.rast
@@ -0,0 +1 @@
ERROR
diff --git a/crates/syntax/test_data/parser/fragments/stmt/err/0000_unterminated_expr.rs b/crates/syntax/test_data/parser/fragments/stmt/err/0000_unterminated_expr.rs
new file mode 100644
index 000000000..ca49acb07
--- /dev/null
+++ b/crates/syntax/test_data/parser/fragments/stmt/err/0000_unterminated_expr.rs
@@ -0,0 +1 @@
1 +
diff --git a/crates/syntax/test_data/parser/fragments/stmt/ok/0000_expr.rast b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_expr.rast
new file mode 100644
index 000000000..274fdf16d
--- /dev/null
+++ b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_expr.rast
@@ -0,0 +1,9 @@
1[email protected]
2 [email protected]
3 [email protected]
4 [email protected] "1"
5 [email protected] " "
6 [email protected] "+"
7 [email protected] " "
8 [email protected]
9 [email protected] "1"
diff --git a/crates/syntax/test_data/parser/fragments/stmt/ok/0000_expr.rs b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_expr.rs
new file mode 100644
index 000000000..8d2f0971e
--- /dev/null
+++ b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_expr.rs
@@ -0,0 +1 @@
1 + 1
diff --git a/crates/syntax/test_data/parser/fragments/stmt/ok/0000_expr_block.rast b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_expr_block.rast
new file mode 100644
index 000000000..6c946091f
--- /dev/null
+++ b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_expr_block.rast
@@ -0,0 +1,69 @@
1[email protected]
2 [email protected]
3 [email protected] "{"
4 [email protected] "\n "
5 [email protected]
6 [email protected] "let"
7 [email protected] " "
8 [email protected]
9 [email protected]
10 [email protected] "x"
11 [email protected] " "
12 [email protected] "="
13 [email protected] " "
14 [email protected]
15 [email protected]
16 [email protected]
17 [email protected]
18 [email protected]
19 [email protected] "foo"
20 [email protected]
21 [email protected] "("
22 [email protected] ")"
23 [email protected] ";"
24 [email protected] "\n "
25 [email protected]
26 [email protected] "let"
27 [email protected] " "
28 [email protected]
29 [email protected]
30 [email protected] "y"
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] "bar"
40 [email protected]
41 [email protected] "("
42 [email protected] ")"
43 [email protected] ";"
44 [email protected] "\n "
45 [email protected]
46 [email protected]
47 [email protected]
48 [email protected]
49 [email protected]
50 [email protected] "Ok"
51 [email protected]
52 [email protected] "("
53 [email protected]
54 [email protected]
55 [email protected]
56 [email protected]
57 [email protected]
58 [email protected] "x"
59 [email protected] " "
60 [email protected] "+"
61 [email protected] " "
62 [email protected]
63 [email protected]
64 [email protected]
65 [email protected]
66 [email protected] "y"
67 [email protected] ")"
68 [email protected] "\n"
69 [email protected] "}"
diff --git a/crates/syntax/test_data/parser/fragments/stmt/ok/0000_expr_block.rs b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_expr_block.rs
new file mode 100644
index 000000000..ffa5c1e66
--- /dev/null
+++ b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_expr_block.rs
@@ -0,0 +1,5 @@
1{
2 let x = foo();
3 let y = bar();
4 Ok(x + y)
5}
diff --git a/crates/syntax/test_data/parser/fragments/stmt/ok/0000_fn_call.rast b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_fn_call.rast
new file mode 100644
index 000000000..8c186da93
--- /dev/null
+++ b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_fn_call.rast
@@ -0,0 +1,11 @@
1[email protected]
2 [email protected]
3 [email protected]
4 [email protected]
5 [email protected]
6 [email protected]
7 [email protected] "foo"
8 [email protected]
9 [email protected] "("
10 [email protected] ")"
11 [email protected] ";"
diff --git a/crates/syntax/test_data/parser/fragments/stmt/ok/0000_fn_call.rs b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_fn_call.rs
new file mode 100644
index 000000000..a280f9a5c
--- /dev/null
+++ b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_fn_call.rs
@@ -0,0 +1 @@
foo();
diff --git a/crates/syntax/test_data/parser/fragments/stmt/ok/0000_let_stmt.rast b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_let_stmt.rast
new file mode 100644
index 000000000..8ab38da21
--- /dev/null
+++ b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_let_stmt.rast
@@ -0,0 +1,12 @@
1[email protected]
2 [email protected] "let"
3 [email protected] " "
4 [email protected]
5 [email protected]
6 [email protected] "x"
7 [email protected] " "
8 [email protected] "="
9 [email protected] " "
10 [email protected]
11 [email protected] "10"
12 [email protected] ";"
diff --git a/crates/syntax/test_data/parser/fragments/stmt/ok/0000_let_stmt.rs b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_let_stmt.rs
new file mode 100644
index 000000000..de8a7f1fc
--- /dev/null
+++ b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_let_stmt.rs
@@ -0,0 +1 @@
let x = 10;
diff --git a/crates/syntax/test_data/parser/fragments/stmt/ok/0000_macro_let_stmt.rast b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_macro_let_stmt.rast
new file mode 100644
index 000000000..81d6df29a
--- /dev/null
+++ b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_macro_let_stmt.rast
@@ -0,0 +1,21 @@
1[email protected]
2 [email protected]
3 [email protected]
4 [email protected]
5 [email protected]
6 [email protected] "m1"
7 [email protected] "!"
8 [email protected]
9 [email protected] "{"
10 [email protected] " "
11 [email protected] "let"
12 [email protected] " "
13 [email protected] "a"
14 [email protected] " "
15 [email protected] "="
16 [email protected] " "
17 [email protected] "0"
18 [email protected] ";"
19 [email protected] " "
20 [email protected] "}"
21 [email protected] ";"
diff --git a/crates/syntax/test_data/parser/fragments/stmt/ok/0000_macro_let_stmt.rs b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_macro_let_stmt.rs
new file mode 100644
index 000000000..075f30159
--- /dev/null
+++ b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_macro_let_stmt.rs
@@ -0,0 +1 @@
m1!{ let a = 0; };
diff --git a/crates/syntax/test_data/parser/fragments/stmt/ok/0000_macro_unterminated_let_stmt.rast b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_macro_unterminated_let_stmt.rast
new file mode 100644
index 000000000..81d6df29a
--- /dev/null
+++ b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_macro_unterminated_let_stmt.rast
@@ -0,0 +1,21 @@
1[email protected]
2 [email protected]
3 [email protected]
4 [email protected]
5 [email protected]
6 [email protected] "m1"
7 [email protected] "!"
8 [email protected]
9 [email protected] "{"
10 [email protected] " "
11 [email protected] "let"
12 [email protected] " "
13 [email protected] "a"
14 [email protected] " "
15 [email protected] "="
16 [email protected] " "
17 [email protected] "0"
18 [email protected] ";"
19 [email protected] " "
20 [email protected] "}"
21 [email protected] ";"
diff --git a/crates/syntax/test_data/parser/fragments/stmt/ok/0000_macro_unterminated_let_stmt.rs b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_macro_unterminated_let_stmt.rs
new file mode 100644
index 000000000..075f30159
--- /dev/null
+++ b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_macro_unterminated_let_stmt.rs
@@ -0,0 +1 @@
m1!{ let a = 0; };
diff --git a/crates/syntax/test_data/parser/fragments/stmt/ok/0000_struct_item.rast b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_struct_item.rast
new file mode 100644
index 000000000..64c5d2969
--- /dev/null
+++ b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_struct_item.rast
@@ -0,0 +1,22 @@
1[email protected]
2 [email protected] "struct"
3 [email protected] " "
4 [email protected]
5 [email protected] "Foo"
6 [email protected] " "
7 [email protected]
8 [email protected] "{"
9 [email protected] "\n "
10 [email protected]
11 [email protected]
12 [email protected] "bar"
13 [email protected] ":"
14 [email protected] " "
15 [email protected]
16 [email protected]
17 [email protected]
18 [email protected]
19 [email protected] "u32"
20 [email protected] ","
21 [email protected] "\n"
22 [email protected] "}"
diff --git a/crates/syntax/test_data/parser/fragments/stmt/ok/0000_struct_item.rs b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_struct_item.rs
new file mode 100644
index 000000000..e5473e3ac
--- /dev/null
+++ b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_struct_item.rs
@@ -0,0 +1,3 @@
1struct Foo {
2 bar: u32,
3}
diff --git a/crates/syntax/test_data/parser/fragments/stmt/ok/0000_unterminated_fn_call.rast b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_unterminated_fn_call.rast
new file mode 100644
index 000000000..9089906bc
--- /dev/null
+++ b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_unterminated_fn_call.rast
@@ -0,0 +1,10 @@
1[email protected]
2 [email protected]
3 [email protected]
4 [email protected]
5 [email protected]
6 [email protected]
7 [email protected] "foo"
8 [email protected]
9 [email protected] "("
10 [email protected] ")"
diff --git a/crates/syntax/test_data/parser/fragments/stmt/ok/0000_unterminated_fn_call.rs b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_unterminated_fn_call.rs
new file mode 100644
index 000000000..eb28ef440
--- /dev/null
+++ b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_unterminated_fn_call.rs
@@ -0,0 +1 @@
foo()
diff --git a/crates/syntax/test_data/parser/fragments/stmt/ok/0000_unterminated_let_stmt.rast b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_unterminated_let_stmt.rast
new file mode 100644
index 000000000..37663671f
--- /dev/null
+++ b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_unterminated_let_stmt.rast
@@ -0,0 +1,11 @@
1[email protected]
2 [email protected] "let"
3 [email protected] " "
4 [email protected]
5 [email protected]
6 [email protected] "x"
7 [email protected] " "
8 [email protected] "="
9 [email protected] " "
10 [email protected]
11 [email protected] "10"
diff --git a/crates/syntax/test_data/parser/fragments/stmt/ok/0000_unterminated_let_stmt.rs b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_unterminated_let_stmt.rs
new file mode 100644
index 000000000..78364b2a9
--- /dev/null
+++ b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_unterminated_let_stmt.rs
@@ -0,0 +1 @@
let x = 10