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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ quote = "1.0"
syn = { version = "1.0.61", features = ["full", "visit-mut"] }

[dev-dependencies]
futures = "0.3"
rustversion = "1.0"
tracing = "0.1.14"
tracing-attributes = "0.1.14"
Expand Down
11 changes: 9 additions & 2 deletions src/receiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,16 @@ impl VisitMut for ReplaceSelf {

fn visit_item_mut(&mut self, i: &mut Item) {
// Visit `macro_rules!` because locally defined macros can refer to
// `self`. Otherwise, do not recurse into nested items.
// `self`.
//
// Visit `futures::select` and similar select macros, which commonly
// appear syntactically like an item despite expanding to an expression.
//
// Otherwise, do not recurse into nested items.
if let Item::Macro(i) = i {
if i.mac.path.is_ident("macro_rules") {
if i.mac.path.is_ident("macro_rules")
|| i.mac.path.segments.last().unwrap().ident == "select"
{
self.visit_macro_mut(&mut i.mac)
}
}
Expand Down
26 changes: 26 additions & 0 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1335,3 +1335,29 @@ pub mod issue158 {
}
}
}

// https://github.com/dtolnay/async-trait/issues/161
#[allow(clippy::mut_mut)]
pub mod issue161 {
use async_trait::async_trait;
use futures::future::FutureExt;
use std::sync::Arc;

#[async_trait]
pub trait Trait {
async fn f(self: Arc<Self>);
}

pub struct MyStruct(bool);

#[async_trait]
impl Trait for MyStruct {
async fn f(self: Arc<Self>) {
futures::select! {
_ = async {
println!("{}", self.0);
}.fuse() => {}
}
}
}
}