Skip to content

Commit 7ff3e08

Browse files
committed
Added support to Parse ASYNC function
Fixes issue Rust-GCC#2560 The parser now parses ASYNC functions. gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_item):Added ASYNC case. (Parser::parse_vis_item):Added a switch case to handel ASYNC. gcc/testsuite/ChangeLog: * rust/compile/issue-2650.rs: New test. Signed-off-by: M V V S Manoj Kumar <[email protected]>
1 parent 9864d7f commit 7ff3e08

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

gcc/rust/parse/rust-parse-impl.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,8 @@ Parser<ManagedTokenSource>::parse_item (bool called_from_statement)
11091109
add_error (std::move (error));
11101110
}
11111111
return nullptr;
1112+
1113+
case ASYNC:
11121114
case PUB:
11131115
case MOD:
11141116
case EXTERN_TOK:
@@ -1385,6 +1387,25 @@ Parser<ManagedTokenSource>::parse_vis_item (AST::AttrVec outer_attrs)
13851387
lexer.skip_token (1); // TODO: is this right thing to do?
13861388
return nullptr;
13871389
}
1390+
case ASYNC:
1391+
t = lexer.peek_token (1);
1392+
1393+
switch (t->get_id ())
1394+
{
1395+
case UNSAFE:
1396+
case FN_TOK:
1397+
return parse_function (std::move (vis), std::move (outer_attrs));
1398+
1399+
default:
1400+
add_error (
1401+
Error (t->get_locus (),
1402+
"unexpected token %qs in some sort of async production",
1403+
t->get_token_description ()));
1404+
1405+
lexer.skip_token (1);
1406+
return nullptr;
1407+
}
1408+
13881409
case STATIC_TOK:
13891410
return parse_static_item (std::move (vis), std::move (outer_attrs));
13901411
case AUTO:
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pub async fn a() -> u32 {
2+
1
3+
}

0 commit comments

Comments
 (0)