aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-07-30 13:32:19 +0100
committerAleksey Kladov <[email protected]>2018-07-30 13:32:19 +0100
commitd39198490f878a9ae395af1cf923fb7375de4548 (patch)
tree5e8d63e20abc8c293e6ba80f0391f9119989aa35
parent333e140a50658151002c9287aa68855358bedd56 (diff)
fn ret type
-rw-r--r--src/parser/grammar/items/mod.rs6
-rw-r--r--tests/data/parser/inline/0038_fn_item_ret_type.rs2
-rw-r--r--tests/data/parser/inline/0038_fn_item_ret_type.txt31
-rw-r--r--tools/src/bin/main.rs1
4 files changed, 39 insertions, 1 deletions
diff --git a/src/parser/grammar/items/mod.rs b/src/parser/grammar/items/mod.rs
index 5d8d57a80..d059833a0 100644
--- a/src/parser/grammar/items/mod.rs
+++ b/src/parser/grammar/items/mod.rs
@@ -206,6 +206,7 @@ fn extern_block(p: &mut Parser) {
206 p.expect(R_CURLY); 206 p.expect(R_CURLY);
207} 207}
208 208
209
209fn fn_item(p: &mut Parser) { 210fn fn_item(p: &mut Parser) {
210 assert!(p.at(FN_KW)); 211 assert!(p.at(FN_KW));
211 p.bump(); 212 p.bump();
@@ -216,7 +217,10 @@ fn fn_item(p: &mut Parser) {
216 } else { 217 } else {
217 p.error("expected function arguments"); 218 p.error("expected function arguments");
218 } 219 }
219 220 // test fn_item_ret_type
221 // fn foo() {}
222 // fn bar() -> () {}
223 fn_ret_type(p);
220 block(p); 224 block(p);
221 225
222 fn block(p: &mut Parser) { 226 fn block(p: &mut Parser) {
diff --git a/tests/data/parser/inline/0038_fn_item_ret_type.rs b/tests/data/parser/inline/0038_fn_item_ret_type.rs
new file mode 100644
index 000000000..d22d8cada
--- /dev/null
+++ b/tests/data/parser/inline/0038_fn_item_ret_type.rs
@@ -0,0 +1,2 @@
1fn foo() {}
2fn bar() -> () {}
diff --git a/tests/data/parser/inline/0038_fn_item_ret_type.txt b/tests/data/parser/inline/0038_fn_item_ret_type.txt
new file mode 100644
index 000000000..f7802c54e
--- /dev/null
+++ b/tests/data/parser/inline/0038_fn_item_ret_type.txt
@@ -0,0 +1,31 @@
1FILE@[0; 30)
2 FN_ITEM@[0; 12)
3 FN_KW@[0; 2)
4 NAME@[2; 6)
5 WHITESPACE@[2; 3)
6 IDENT@[3; 6) "foo"
7 L_PAREN@[6; 7)
8 R_PAREN@[7; 8)
9 BLOCK@[8; 12)
10 WHITESPACE@[8; 9)
11 L_CURLY@[9; 10)
12 R_CURLY@[10; 11)
13 WHITESPACE@[11; 12)
14 FN_ITEM@[12; 30)
15 FN_KW@[12; 14)
16 NAME@[14; 18)
17 WHITESPACE@[14; 15)
18 IDENT@[15; 18) "bar"
19 L_PAREN@[18; 19)
20 R_PAREN@[19; 20)
21 WHITESPACE@[20; 21)
22 THIN_ARROW@[21; 23)
23 TUPLE_TYPE@[23; 27)
24 WHITESPACE@[23; 24)
25 L_PAREN@[24; 25)
26 R_PAREN@[25; 26)
27 WHITESPACE@[26; 27)
28 BLOCK@[27; 30)
29 L_CURLY@[27; 28)
30 R_CURLY@[28; 29)
31 WHITESPACE@[29; 30)
diff --git a/tools/src/bin/main.rs b/tools/src/bin/main.rs
index 125930127..f4f6e82ae 100644
--- a/tools/src/bin/main.rs
+++ b/tools/src/bin/main.rs
@@ -55,6 +55,7 @@ fn update(path: &Path, contents: &str, verify: bool) -> Result<()> {
55 if verify { 55 if verify {
56 bail!("`{}` is not up-to-date", path.display()); 56 bail!("`{}` is not up-to-date", path.display());
57 } 57 }
58 eprintln!("updating {}", path.display());
58 fs::write(path, contents)?; 59 fs::write(path, contents)?;
59 Ok(()) 60 Ok(())
60} 61}