File tree Expand file tree Collapse file tree 3 files changed +36
-2
lines changed Expand file tree Collapse file tree 3 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ quote = "1.0"
19
19
syn = { version = " 1.0.61" , features = [" full" , " visit-mut" ] }
20
20
21
21
[dev-dependencies ]
22
+ futures = " 0.3"
22
23
rustversion = " 1.0"
23
24
tracing = " 0.1.14"
24
25
tracing-attributes = " 0.1.14"
Original file line number Diff line number Diff line change @@ -151,9 +151,16 @@ impl VisitMut for ReplaceSelf {
151
151
152
152
fn visit_item_mut ( & mut self , i : & mut Item ) {
153
153
// Visit `macro_rules!` because locally defined macros can refer to
154
- // `self`. Otherwise, do not recurse into nested items.
154
+ // `self`.
155
+ //
156
+ // Visit `futures::select` and similar select macros, which commonly
157
+ // appear syntactically like an item despite expanding to an expression.
158
+ //
159
+ // Otherwise, do not recurse into nested items.
155
160
if let Item :: Macro ( i) = i {
156
- if i. mac . path . is_ident ( "macro_rules" ) {
161
+ if i. mac . path . is_ident ( "macro_rules" )
162
+ || i. mac . path . segments . last ( ) . unwrap ( ) . ident == "select"
163
+ {
157
164
self . visit_macro_mut ( & mut i. mac )
158
165
}
159
166
}
Original file line number Diff line number Diff line change @@ -1335,3 +1335,29 @@ pub mod issue158 {
1335
1335
}
1336
1336
}
1337
1337
}
1338
+
1339
+ // https://github.com/dtolnay/async-trait/issues/161
1340
+ #[ allow( clippy:: mut_mut) ]
1341
+ pub mod issue161 {
1342
+ use async_trait:: async_trait;
1343
+ use futures:: future:: FutureExt ;
1344
+ use std:: sync:: Arc ;
1345
+
1346
+ #[ async_trait]
1347
+ pub trait Trait {
1348
+ async fn f ( self : Arc < Self > ) ;
1349
+ }
1350
+
1351
+ pub struct MyStruct ( bool ) ;
1352
+
1353
+ #[ async_trait]
1354
+ impl Trait for MyStruct {
1355
+ async fn f ( self : Arc < Self > ) {
1356
+ futures:: select! {
1357
+ _ = async {
1358
+ println!( "{}" , self . 0 ) ;
1359
+ } . fuse( ) => { }
1360
+ }
1361
+ }
1362
+ }
1363
+ }
You can’t perform that action at this time.
0 commit comments