use async_trait::async_trait;
struct Struct;
#[async_trait]
pub trait Trait {
async fn foo();
}
#[async_trait]
impl Trait for Struct {
async fn foo() {
let _ = Self;
// let _ = Struct;
}
}
Error:
error: custom attribute panicked
--> src/lib.rs:19:1
|
19 | #[async_trait]
| ^^^^^^^^^^^^^^
|
= help: message: called `Option::unwrap()` on a `None` value
I traced the error to using Self instead of Struct. non-async functions are not affected. Also the error is different if I change it to Struct { x: u8 }, but not if I cange it to Struct(u8);:
error[E0401]: can't use generic parameters from outer function
--> src/lib.rs:22:17
|
20 | impl Trait for Struct {
| ---- `Self` type implicitly declared here, by this `impl`
21 | async fn foo() {
22 | let _ = Self { x: 0 };
| ^^^^
| |
| use of generic parameter from outer function
| use a type here instead
This time not a panic, but this would compile with Struct instead of Self or in a non-async function.
Example Code:
Error:
I traced the error to using
Self
instead ofStruct
. non-async
functions are not affected. Also the error is different if I change it toStruct { x: u8 }
, but not if I cange it toStruct(u8);
:This time not a panic, but this would compile with
Struct
instead ofSelf
or in a non-async
function.using
async-trait
0.1.19 & Rust 1.39.0PS. thanks for this crate, it's awesome!