Skip to content

Commit

Permalink
Added support to Parse ASYNC function
Browse files Browse the repository at this point in the history
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 <mvvsmanojkumar@gmail.com>
  • Loading branch information
mvvsmk committed Nov 10, 2023
1 parent 9864d7f commit 7ff3e08
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
21 changes: 21 additions & 0 deletions gcc/rust/parse/rust-parse-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,8 @@ Parser<ManagedTokenSource>::parse_item (bool called_from_statement)
add_error (std::move (error));
}
return nullptr;

case ASYNC:
case PUB:
case MOD:
case EXTERN_TOK:
Expand Down Expand Up @@ -1385,6 +1387,25 @@ Parser<ManagedTokenSource>::parse_vis_item (AST::AttrVec outer_attrs)
lexer.skip_token (1); // TODO: is this right thing to do?
return nullptr;
}
case ASYNC:
t = lexer.peek_token (1);

switch (t->get_id ())
{
case UNSAFE:
case FN_TOK:
return parse_function (std::move (vis), std::move (outer_attrs));

default:
add_error (
Error (t->get_locus (),
"unexpected token %qs in some sort of async production",
t->get_token_description ()));

lexer.skip_token (1);
return nullptr;
}

case STATIC_TOK:
return parse_static_item (std::move (vis), std::move (outer_attrs));
case AUTO:
Expand Down
3 changes: 3 additions & 0 deletions gcc/testsuite/rust/compile/issue-2650.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub async fn a() -> u32 {
1
}

0 comments on commit 7ff3e08

Please sign in to comment.