Skip to content

Commit

Permalink
Handle async qualifier inside trait
Browse files Browse the repository at this point in the history
Fixes Rust-GCC#2778

gcc/rust/ChangeLog:

	* parse/rust-parse-impl.h (Parser::parse_trait_impl_item):
	Handled `async` similar to `const`

Signed-off-by: Kushal Pal <[email protected]>
  • Loading branch information
braw-lee committed Dec 15, 2023
1 parent 6c80746 commit 0187d64
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions gcc/rust/parse/rust-parse-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -5761,7 +5761,8 @@ Parser<ManagedTokenSource>::parse_trait_impl_item ()

// branch on next token:
const_TokenPtr t = lexer.peek_token ();
switch (t->get_id ())
auto token_id = t->get_id ();
switch (token_id)
{
case SUPER:
case SELF:
Expand All @@ -5784,6 +5785,7 @@ Parser<ManagedTokenSource>::parse_trait_impl_item ()
// function or method
return parse_trait_impl_function_or_method (visibility,
std::move (outer_attrs));
case ASYNC:
case CONST:
// lookahead to resolve production - could be function/method or const
// item
Expand All @@ -5793,7 +5795,11 @@ Parser<ManagedTokenSource>::parse_trait_impl_item ()
{
case IDENTIFIER:
case UNDERSCORE:
return parse_const_item (visibility, std::move (outer_attrs));
if (token_id == CONST)
return parse_const_item (visibility, std::move (outer_attrs));
// else if token_id == ASYNC
return parse_async_item (visibility, std::move (outer_attrs));

case UNSAFE:
case EXTERN_KW:
case FN_KW:
Expand Down Expand Up @@ -10584,7 +10590,7 @@ Parser<ManagedTokenSource>::parse_pattern ()
{
lexer.skip_token ();
alts.push_back (parse_pattern_no_alt ());
}
}
while (lexer.peek_token ()->get_id () == PIPE);

/* alternates */
Expand Down

0 comments on commit 0187d64

Please sign in to comment.