diff options
author | Jeff Vander Stoep <jeffv@google.com> | 2021-04-21 17:53:57 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-04-21 17:53:57 +0000 |
commit | af5acc173f260c1ebf4a2a25b0da83b86ffeef7f (patch) | |
tree | 9739f4bea3e54934e235716a483b610f81d2504b | |
parent | 5b1ad42c6ce7e3ead02ecef9868d12238041a5ab (diff) | |
parent | 676ed34addf6463f2073da6299dba099bbbcc3cc (diff) | |
download | async-trait-android12-qpr1-release.tar.gz |
Update to 0.1.50 am: f833bced20 am: 6a58d211c4 am: 676ed34addandroid-12.1.0_r9android-12.1.0_r8android-12.1.0_r7android-12.1.0_r22android-12.1.0_r21android-12.1.0_r20android-12.1.0_r19android-12.1.0_r11android-12.1.0_r10android-12.0.0_r32android-12.0.0_r29android-12.0.0_r28android-12.0.0_r27android-12.0.0_r26android-12.0.0_r21android-12.0.0_r20android-12.0.0_r19android-12.0.0_r18android-12.0.0_r16android12L-devandroid12-qpr3-s7-releaseandroid12-qpr3-s6-releaseandroid12-qpr3-s5-releaseandroid12-qpr3-s4-releaseandroid12-qpr3-s3-releaseandroid12-qpr3-s2-releaseandroid12-qpr3-s1-releaseandroid12-qpr3-releaseandroid12-qpr1-releaseandroid12-qpr1-d-s3-releaseandroid12-qpr1-d-s2-releaseandroid12-qpr1-d-s1-releaseandroid12-qpr1-d-releaseandroid12-dev
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/async-trait/+/1682043
Change-Id: I8e743118e3b238baf3bb38bd22a547eaa53ff261
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | Android.bp | 2 | ||||
-rw-r--r-- | Cargo.toml | 11 | ||||
-rw-r--r-- | Cargo.toml.orig | 7 | ||||
-rw-r--r-- | METADATA | 6 | ||||
-rw-r--r-- | TEST_MAPPING | 8 | ||||
-rw-r--r-- | src/receiver.rs | 23 | ||||
-rw-r--r-- | tests/test.rs | 43 |
8 files changed, 84 insertions, 18 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index a638e3f..d7f5c7b 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "a4aab7b9285e4912d16f1f4733cfb99fc8aa37da" + "sha1": "651ddc1131325b08c1b76ae6b65c1f23ca4cf7cf" } } @@ -52,5 +52,5 @@ rust_proc_macro { // dependent_library ["feature_list"] // proc-macro2-1.0.26 "default,proc-macro" // quote-1.0.9 "default,proc-macro" -// syn-1.0.68 "clone-impls,default,derive,extra-traits,full,parsing,printing,proc-macro,quote,visit,visit-mut" +// syn-1.0.69 "clone-impls,default,derive,extra-traits,full,parsing,printing,proc-macro,quote,visit,visit-mut" // unicode-xid-0.2.1 "default" @@ -13,11 +13,12 @@ [package] edition = "2018" name = "async-trait" -version = "0.1.48" +version = "0.1.50" authors = ["David Tolnay <dtolnay@gmail.com>"] description = "Type erasure for async trait methods" documentation = "https://docs.rs/async-trait" readme = "README.md" +keywords = ["async"] license = "MIT OR Apache-2.0" repository = "https://github.com/dtolnay/async-trait" [package.metadata.docs.rs] @@ -34,6 +35,9 @@ version = "1.0" [dependencies.syn] version = "1.0.61" features = ["full", "visit-mut"] +[dev-dependencies.futures] +version = "0.3" + [dev-dependencies.rustversion] version = "1.0" @@ -41,10 +45,7 @@ version = "1.0" version = "0.1.14" [dev-dependencies.tracing-attributes] -version = "0.1.8" - -[dev-dependencies.tracing-futures] -version = "0.2" +version = "0.1.14" [dev-dependencies.trybuild] version = "1.0.19" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index d5599b1..8af0b3b 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "async-trait" -version = "0.1.48" +version = "0.1.50" authors = ["David Tolnay <dtolnay@gmail.com>"] edition = "2018" license = "MIT OR Apache-2.0" @@ -8,6 +8,7 @@ description = "Type erasure for async trait methods" repository = "https://github.com/dtolnay/async-trait" documentation = "https://docs.rs/async-trait" readme = "README.md" +keywords = ["async"] [lib] proc-macro = true @@ -18,10 +19,10 @@ 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.8" -tracing-futures = "0.2" +tracing-attributes = "0.1.14" trybuild = { version = "1.0.19", features = ["diff"] } [package.metadata.docs.rs] @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/async-trait/async-trait-0.1.48.crate" + value: "https://static.crates.io/crates/async-trait/async-trait-0.1.50.crate" } - version: "0.1.48" + version: "0.1.50" license_type: NOTICE last_upgrade_date { year: 2021 month: 4 - day: 1 + day: 21 } } diff --git a/TEST_MAPPING b/TEST_MAPPING new file mode 100644 index 0000000..0f4f93c --- /dev/null +++ b/TEST_MAPPING @@ -0,0 +1,8 @@ +// Generated by update_crate_tests.py for tests that depend on this crate. +{ + "presubmit": [ + { + "name": "authfs_device_test_src_lib" + } + ] +} diff --git a/src/receiver.rs b/src/receiver.rs index 64ab65e..f6ea327 100644 --- a/src/receiver.rs +++ b/src/receiver.rs @@ -2,7 +2,7 @@ use proc_macro2::{Group, Span, TokenStream, TokenTree}; use std::iter::FromIterator; use syn::visit_mut::{self, VisitMut}; use syn::{ - Block, ExprPath, Ident, Item, Macro, Pat, PatIdent, PatPath, Receiver, Signature, Token, + Block, ExprPath, Ident, Item, Macro, Pat, PatIdent, PatPath, Path, Receiver, Signature, Token, TypePath, }; @@ -139,11 +139,28 @@ impl VisitMut for ReplaceSelf { self.prepend_underscore_to_self(i); } + fn visit_path_mut(&mut self, p: &mut Path) { + if p.segments.len() == 1 { + // Replace `self`, but not `self::function`. + self.visit_ident_mut(&mut p.segments[0].ident); + } + for segment in &mut p.segments { + self.visit_path_arguments_mut(&mut segment.arguments); + } + } + 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) } } diff --git a/tests/test.rs b/tests/test.rs index 604d092..6f95576 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -1,6 +1,6 @@ #![cfg_attr( async_trait_nightly_testing, - feature(min_specialization, min_const_generics, type_alias_impl_trait) + feature(min_specialization, min_type_alias_impl_trait) )] #![allow( clippy::let_underscore_drop, @@ -615,7 +615,6 @@ pub mod issue45 { } #[test] - #[should_panic] fn tracing() { // Create the future outside of the subscriber, as no call to tracing // should be made until the future is polled. @@ -1322,3 +1321,43 @@ pub mod issue154 { } } } + +// https://github.com/dtolnay/async-trait/issues/158 +pub mod issue158 { + use async_trait::async_trait; + + fn f() {} + + #[async_trait] + pub trait Trait { + async fn f(&self) { + self::f() + } + } +} + +// 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() => {} + } + } + } +} |