Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle async keyword for regular implementations #2789

Merged
merged 1 commit into from
Jan 17, 2024

Conversation

braw-lee
Copy link
Contributor

@braw-lee braw-lee commented Jan 6, 2024

Fixes #2788
I am not sure how to test this as we don't have to check for error. I was reading up on async functions usage and I think Tokio is required to write small code snippets, which isn't supported by gccrs yet.

@P-E-P
Copy link
Member

P-E-P commented Jan 15, 2024

Fixes #2788 I am not sure how to test this as we don't have to check for error. I was reading up on async functions usage and I think Tokio is required to write small code snippets, which isn't supported by gccrs yet.

@braw-lee You don't need tokio tu use async in rust, there are a lot of different executors (async-std, smol, IIRC even embassy makes use of the async keyword) and you could even do without those.

You're right though when saying that it won't be easy to test as we cannot lower async yet. We only want to make sure the syntax is correct. Here is what you can do, since you modified the parser you could test that it behaves correctly. To do so you need to create an async rust snippet and add it to the testsuite under gcc/testsuite/rust/compile with the following first line:

// { dg-additional-options "-frust-compile-until=lowering" }

This tells the testsuite to pass a flag to the compiler in order to stop before the lowering step. There are a multiple other compile steps, tune the value to your needs but keep in mind the compiler will stop before the selected step.

@braw-lee
Copy link
Contributor Author

thanks, I will try this soon

Fixes Rust-GCC#2788

gcc/rust/ChangeLog:

	* parse/rust-parse-impl.h (Parser::parse_inherent_impl_item):
	Added switch-case for ASYNC token.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-2788.rs: New test.

Signed-off-by: Kushal Pal <[email protected]>
@braw-lee braw-lee marked this pull request as ready for review January 17, 2024 04:20
@braw-lee
Copy link
Contributor Author

@P-E-P as the compiler will stop before lowering step, I made the test case as minimal as possible. Let me know if you were expecting a more verbose test case.

@P-E-P P-E-P added this to the GCC 14.1 release milestone Jan 17, 2024
@P-E-P P-E-P self-requested a review January 17, 2024 13:22
Copy link
Member

@P-E-P P-E-P left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test looks good! Thank you!

@P-E-P P-E-P added this pull request to the merge queue Jan 17, 2024
Copy link
Member

@CohenArthur CohenArthur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Merged via the queue into Rust-GCC:master with commit 0cd26bd Jan 17, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Unhandled async for regular implementations.
3 participants