Emit error on async trait functions
you can add the same check for `async` functions, even if that is about to change soon.
Originally posted by @CohenArthur in https://github.com/Rust-GCC/gccrs/pull/2753#discussion_r1411796349
error[E0706]: functions in traits cannot be declared `async`
--> src/lib.rs:2:5
|
2 | async fn titi();
| -----^^^^^^^^^^^
| |
| `async` because of this
|
= note: `async` trait functions are not currently supported
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
I want to fix this
I added a check and test for async function inside a trait but gccrs fails to recognize async as a token inside trait impl
test.rs:6:5: error: unrecognised token ‘async’ for item in trait impl
6 | async fn f() -> u32 {
| ^~~~~
test.rs:6:5: error: failed to parse trait impl item in trait impl
test.rs:6:5: error: failed to parse item in crate
is async token not fully supported yet? I was trying to step through the lexer with gdb to find out but for some reason it skips over some code even with -O0 flag enabled
is
asynctoken not fully supported yet? I was trying to step through the lexer with gdb to find out but for some reason it skips over some code even with -O0 flag enabled
AFAIK async token is supported by the lexer, we already have multiple async nodes in our ast. For example the parse_async_item function make use of it indirectly.
yes, looks like async is supported
this makes me think there is an unhandled case for async token when we are inside a trait
I will look into it in a few days
@P-E-P, @braw-lee, @CohenArthur, is it correct that this issue got closed via #2944 "Merge upstream, 2024-03-09" (why wasn't it then already closed via a GCC/Rust master branch commit?), or remains there work to be done here?
https://github.com/Rust-GCC/gccrs/pull/2779 the second commit of this PR fixed this issue
I think it wasn't closed because I didn't mention the issue #2767 in the message