gccrs icon indicating copy to clipboard operation
gccrs copied to clipboard

Emit error on async trait functions

Open P-E-P opened this issue 2 years ago • 5 comments

          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

P-E-P avatar Dec 01 '23 09:12 P-E-P

I want to fix this

braw-lee avatar Dec 13 '23 14:12 braw-lee

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

braw-lee avatar Dec 14 '23 04:12 braw-lee

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

braw-lee avatar Dec 14 '23 04:12 braw-lee

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

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.

P-E-P avatar Dec 14 '23 08:12 P-E-P

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

braw-lee avatar Dec 15 '23 13:12 braw-lee

@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?

tschwinge avatar Apr 12 '24 07:04 tschwinge

https://github.com/Rust-GCC/gccrs/pull/2779 the second commit of this PR fixed this issue

braw-lee avatar Apr 12 '24 07:04 braw-lee

I think it wasn't closed because I didn't mention the issue #2767 in the message

braw-lee avatar Apr 12 '24 08:04 braw-lee