Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/receiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ pub fn has_self_in_block(block: &mut Block) -> bool {
struct HasSelf(bool);

impl VisitMut for HasSelf {
fn visit_expr_path_mut(&mut self, expr: &mut ExprPath) {
self.0 |= expr.path.segments[0].ident == "Self";
visit_mut::visit_expr_path_mut(self, expr);
}

fn visit_type_path_mut(&mut self, ty: &mut TypePath) {
self.0 |= ty.path.segments[0].ident == "Self";
visit_mut::visit_type_path_mut(self, ty);
Expand Down
19 changes: 19 additions & 0 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,3 +341,22 @@ mod issue28 {
async fn h(); // do not chain
}
}

// https://github.com/dtolnay/async-trait/issues/31
pub mod issue31 {
use async_trait::async_trait;

pub struct Struct<'a> {
pub name: &'a str,
}

#[async_trait]
pub trait Trait<'a> {
async fn hello(thing: Struct<'a>) -> String;
async fn hello_twice(one: Struct<'a>, two: Struct<'a>) -> String {
let str1 = Self::hello(one).await;
let str2 = Self::hello(two).await;
str1 + &str2
}
}
}