You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use async_trait::async_trait;// 0.1.30#[async_trait]pubtraitFooTrait{#[async_trait]// <-- This shouldn't be here.asyncfna();asyncfnfoo();}structFooStruct{}#[async_trait]implFooTraitforFooStruct{asyncfnfoo(){}}
Here's the build output:
Compiling playground v0.0.1 (/playground)
error: expected one of: `unsafe`, `pub`, `trait`, `impl`
error: aborting due to previous error
error: could not compile `playground`.
To learn more, run the command again with --verbose.
Obviously I've applied the macro incorrectly here, but it's unfortunate that the compiler can't tell me where the problem is. Is this a known issue, maybe because the code that doesn't compile was created by the macro? Thanks in advance, and sorry if I'm down the wrong path here!
The text was updated successfully, but these errors were encountered:
davepacheco
changed the title
incorrect use led to compile errors with no location information
incorrect use led to compile error with no location information
May 7, 2020
Confirmed fixed in rustc master. The error is not so good but it is at least correctly located. (The error is the inner #[async_trait] attempting to interpret your async fn as a trait or trait impl.)
I ran into a case where I used async_trait incorrectly and the result was a compiler error with no line number information. This seems more likely a compiler issue, not async_trait, but I had trouble reproducing the issue without async_trait. Here's my example:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=a41abc2ee0d6fc3714ff09e8172aae94
Copying the code here:
Here's the build output:
Obviously I've applied the macro incorrectly here, but it's unfortunate that the compiler can't tell me where the problem is. Is this a known issue, maybe because the code that doesn't compile was created by the macro? Thanks in advance, and sorry if I'm down the wrong path here!
The text was updated successfully, but these errors were encountered: