Skip to content

Commit

Permalink
Merge pull request #284 from dtolnay/selfinblock
Browse files Browse the repository at this point in the history
Omit `Self: 'async_trait` bound in impl when not needed by signature
  • Loading branch information
dtolnay authored Jan 6, 2025
2 parents 4c8406d + 9456e54 commit 0c2e108
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub fn expand(input: &mut Item, is_local: bool) {
ImplItem::Fn(method) if method.sig.asyncness.is_some() => {
let sig = &mut method.sig;
let block = &mut method.block;
let has_self = has_self_in_sig(sig) || has_self_in_block(block);
let has_self = has_self_in_sig(sig);
transform_block(context, sig, block);
transform_sig(context, sig, has_self, false, is_local);
method.attrs.push(lint_suppress_with_body());
Expand Down
20 changes: 20 additions & 0 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1683,3 +1683,23 @@ pub mod issue281 {
}
}
}

pub mod issue283 {
use async_trait::async_trait;

#[async_trait]
pub trait Trait {
async fn a();
}

pub trait Bound {
fn b();
}

#[async_trait]
impl<T: Bound> Trait for T {
async fn a() {
Self::b();
}
}
}

0 comments on commit 0c2e108

Please sign in to comment.