Skip to content

incorrect use led to compile error with no location information #95

Closed
@davepacheco

Description

@davepacheco

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:

use async_trait::async_trait; // 0.1.30

#[async_trait]
pub trait FooTrait {
    #[async_trait] // <-- This shouldn't be here.
    async fn a();
    async fn foo();
}

struct FooStruct {}

#[async_trait]
impl FooTrait for FooStruct {
    async fn foo() {}
}

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions