fn ret type

This commit is contained in:
Aleksey Kladov 2018-07-30 15:32:19 +03:00
parent 333e140a50
commit d39198490f
4 changed files with 39 additions and 1 deletions

View file

@ -206,6 +206,7 @@ fn extern_block(p: &mut Parser) {
p.expect(R_CURLY);
}
fn fn_item(p: &mut Parser) {
assert!(p.at(FN_KW));
p.bump();
@ -216,7 +217,10 @@ fn fn_item(p: &mut Parser) {
} else {
p.error("expected function arguments");
}
// test fn_item_ret_type
// fn foo() {}
// fn bar() -> () {}
fn_ret_type(p);
block(p);
fn block(p: &mut Parser) {

View file

@ -0,0 +1,2 @@
fn foo() {}
fn bar() -> () {}

View file

@ -0,0 +1,31 @@
FILE@[0; 30)
FN_ITEM@[0; 12)
FN_KW@[0; 2)
NAME@[2; 6)
WHITESPACE@[2; 3)
IDENT@[3; 6) "foo"
L_PAREN@[6; 7)
R_PAREN@[7; 8)
BLOCK@[8; 12)
WHITESPACE@[8; 9)
L_CURLY@[9; 10)
R_CURLY@[10; 11)
WHITESPACE@[11; 12)
FN_ITEM@[12; 30)
FN_KW@[12; 14)
NAME@[14; 18)
WHITESPACE@[14; 15)
IDENT@[15; 18) "bar"
L_PAREN@[18; 19)
R_PAREN@[19; 20)
WHITESPACE@[20; 21)
THIN_ARROW@[21; 23)
TUPLE_TYPE@[23; 27)
WHITESPACE@[23; 24)
L_PAREN@[24; 25)
R_PAREN@[25; 26)
WHITESPACE@[26; 27)
BLOCK@[27; 30)
L_CURLY@[27; 28)
R_CURLY@[28; 29)
WHITESPACE@[29; 30)

View file

@ -55,6 +55,7 @@ fn update(path: &Path, contents: &str, verify: bool) -> Result<()> {
if verify {
bail!("`{}` is not up-to-date", path.display());
}
eprintln!("updating {}", path.display());
fs::write(path, contents)?;
Ok(())
}