diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-11-25 04:11:06 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-11-25 04:11:06 +0000 |
commit | 3319c5bfa9423706541c8b26df65a027eb475e93 (patch) | |
tree | 5f68104e9962a2fb34e1ce6de499f96278355ff1 | |
parent | 063752fac875c4159e27796afd17ecc730255445 (diff) | |
parent | 8eecee95bb951055ece8f1e2df232a4b4b898fad (diff) | |
download | async-trait-android14-qpr2-s3-release.tar.gz |
Snap for 11142129 from 8eecee95bb951055ece8f1e2df232a4b4b898fad to 24Q1-releaseandroid-14.0.0_r33android-14.0.0_r32android-14.0.0_r31android-14.0.0_r30android-14.0.0_r29android14-qpr2-s3-releaseandroid14-qpr2-s2-releaseandroid14-qpr2-s1-releaseandroid14-qpr2-release
Change-Id: I234b9a69c51c8efa9d71a36d1daa29d8c2094ed6
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | .github/workflows/ci.yml | 24 | ||||
-rw-r--r-- | Android.bp | 2 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | Cargo.toml.orig | 2 | ||||
-rw-r--r-- | METADATA | 22 | ||||
-rw-r--r-- | build.rs | 6 | ||||
-rw-r--r-- | src/lib.rs | 7 | ||||
-rw-r--r-- | tests/ui/consider-restricting.stderr | 6 | ||||
-rw-r--r-- | tests/ui/no-attribute-macro.rs | 13 | ||||
-rw-r--r-- | tests/ui/no-attribute-macro.stderr | 14 | ||||
-rw-r--r-- | tests/ui/send-not-implemented.stderr | 15 |
12 files changed, 76 insertions, 39 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 6c6616b..63874a0 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,6 +1,6 @@ { "git": { - "sha1": "f07c8568702978c72d0c282f719a4649065ac517" + "sha1": "265979b07a9af573e1edd3b2a9b179533cfa7a6c" }, "path_in_vcs": "" }
\ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 942dd36..eef1ba6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: rust: [nightly, beta, stable, 1.56.0] timeout-minutes: 45 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: toolchain: ${{matrix.rust}} @@ -46,18 +46,32 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 45 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@nightly - run: cargo generate-lockfile -Z minimal-versions - run: cargo check --locked + doc: + name: Documentation + needs: pre_ci + if: needs.pre_ci.outputs.continue + runs-on: ubuntu-latest + timeout-minutes: 45 + env: + RUSTDOCFLAGS: -Dwarnings + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@nightly + - uses: dtolnay/install@cargo-docs-rs + - run: cargo docs-rs + clippy: name: Clippy runs-on: ubuntu-latest if: github.event_name != 'pull_request' timeout-minutes: 45 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@clippy - run: cargo clippy --tests -- -Dclippy::all -Dclippy::pedantic @@ -68,7 +82,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 45 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@miri - run: cargo miri setup - run: cargo miri test @@ -81,6 +95,6 @@ jobs: if: github.event_name != 'pull_request' timeout-minutes: 45 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/install@cargo-outdated - run: cargo outdated --workspace --exit-code 1 @@ -41,7 +41,7 @@ rust_proc_macro { name: "libasync_trait", crate_name: "async_trait", cargo_env_compat: true, - cargo_pkg_version: "0.1.73", + cargo_pkg_version: "0.1.74", srcs: ["src/lib.rs"], edition: "2021", rustlibs: [ @@ -13,7 +13,7 @@ edition = "2021" rust-version = "1.56" name = "async-trait" -version = "0.1.73" +version = "0.1.74" authors = ["David Tolnay <dtolnay@gmail.com>"] description = "Type erasure for async trait methods" documentation = "https://docs.rs/async-trait" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 3c8f287..e0e3762 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "async-trait" -version = "0.1.73" +version = "0.1.74" authors = ["David Tolnay <dtolnay@gmail.com>"] categories = ["asynchronous", "no-std"] description = "Type erasure for async trait methods" @@ -5,19 +5,19 @@ name: "async-trait" description: "Type erasure for async trait methods" third_party { - url { - type: HOMEPAGE - value: "https://crates.io/crates/async-trait" - } - url { - type: ARCHIVE - value: "https://static.crates.io/crates/async-trait/async-trait-0.1.73.crate" - } - version: "0.1.73" license_type: NOTICE last_upgrade_date { year: 2023 - month: 8 - day: 16 + month: 11 + day: 24 + } + identifier { + type: "HOMEPAGE" + value: "https://crates.io/crates/async-trait" + } + identifier { + type: "ARCHIVE" + value: "https://static.crates.io/crates/async-trait/async-trait-0.1.74.crate" + version: "0.1.74" } } @@ -3,7 +3,7 @@ use std::process::Command; use std::str; fn main() { - println!("cargo:rerun-if-changed=build.rs"); + println!("cargo:rerun-if-env-changed=DOCS_RS"); let compiler = match rustc_minor_version() { Some(compiler) => compiler, @@ -17,6 +17,10 @@ fn main() { if compiler < 47 { println!("cargo:rustc-cfg=self_span_hack"); } + + if compiler >= 75 && env::var_os("DOCS_RS").is_none() { + println!("cargo:rustc-cfg=native_async_fn_in_trait"); + } } fn rustc_minor_version() -> Option<u32> { @@ -12,11 +12,12 @@ //! Rust 1.39 did not include support for async fn in traits. Trying to include //! an async fn in a trait produces the following error: //! -//! ```compile_fail +#![cfg_attr(not(native_async_fn_in_trait), doc = "```compile_fail")] +#![cfg_attr(native_async_fn_in_trait, doc = "```")] //! trait MyTrait { //! async fn f() {} //! } -//! ``` +#![doc = "```"] //! //! ```text //! error[E0706]: trait fns cannot be declared `async` @@ -303,7 +304,7 @@ //! let object = &value as &dyn ObjectSafe; //! ``` -#![doc(html_root_url = "https://docs.rs/async-trait/0.1.73")] +#![doc(html_root_url = "https://docs.rs/async-trait/0.1.74")] #![allow( clippy::default_trait_access, clippy::doc_markdown, diff --git a/tests/ui/consider-restricting.stderr b/tests/ui/consider-restricting.stderr index 5f7fd00..66e9637 100644 --- a/tests/ui/consider-restricting.stderr +++ b/tests/ui/consider-restricting.stderr @@ -4,13 +4,12 @@ error: future cannot be sent between threads safely 16 | async fn publish<T: IntoUrl>(&self, url: T) {} | ^^ future created by async block is not `Send` | - = note: consider using `std::sync::Arc<T>`; for more information visit <https://doc.rust-lang.org/book/ch16-03-shared-state.html> note: captured value is not `Send` --> tests/ui/consider-restricting.rs:16:41 | 16 | async fn publish<T: IntoUrl>(&self, url: T) {} | ^^^ has type `T` which is not `Send` - = note: required for the cast from `Pin<Box<[async block@$DIR/tests/ui/consider-restricting.rs:16:49: 16:51]>>` to `Pin<Box<(dyn Future<Output = ()> + Send + 'async_trait)>>` + = note: required for the cast from `Pin<Box<{async block@$DIR/tests/ui/consider-restricting.rs:16:49: 16:51}>>` to `Pin<Box<(dyn Future<Output = ()> + Send + 'async_trait)>>` help: consider further restricting this bound | 16 | async fn publish<T: IntoUrl + std::marker::Send>(&self, url: T) {} @@ -22,13 +21,12 @@ error: future cannot be sent between threads safely 23 | async fn publish<T>(&self, url: T) {} | ^^ future created by async block is not `Send` | - = note: consider using `std::sync::Arc<T>`; for more information visit <https://doc.rust-lang.org/book/ch16-03-shared-state.html> note: captured value is not `Send` --> tests/ui/consider-restricting.rs:23:32 | 23 | async fn publish<T>(&self, url: T) {} | ^^^ has type `T` which is not `Send` - = note: required for the cast from `Pin<Box<[async block@$DIR/tests/ui/consider-restricting.rs:23:40: 23:42]>>` to `Pin<Box<(dyn Future<Output = ()> + Send + 'async_trait)>>` + = note: required for the cast from `Pin<Box<{async block@$DIR/tests/ui/consider-restricting.rs:23:40: 23:42}>>` to `Pin<Box<(dyn Future<Output = ()> + Send + 'async_trait)>>` help: consider further restricting this bound | 23 | async fn publish<T + std::marker::Send>(&self, url: T) {} diff --git a/tests/ui/no-attribute-macro.rs b/tests/ui/no-attribute-macro.rs new file mode 100644 index 0000000..c0fb431 --- /dev/null +++ b/tests/ui/no-attribute-macro.rs @@ -0,0 +1,13 @@ +pub trait Trait { + async fn method(&self); +} + +pub struct Struct; + +impl Trait for Struct { + async fn method(&self) {} +} + +fn main() { + let _: &dyn Trait; +} diff --git a/tests/ui/no-attribute-macro.stderr b/tests/ui/no-attribute-macro.stderr new file mode 100644 index 0000000..35d8d5a --- /dev/null +++ b/tests/ui/no-attribute-macro.stderr @@ -0,0 +1,14 @@ +error[E0038]: the trait `Trait` cannot be made into an object + --> tests/ui/no-attribute-macro.rs:12:12 + | +12 | let _: &dyn Trait; + | ^^^^^^^^^^ `Trait` cannot be made into an object + | +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> + --> tests/ui/no-attribute-macro.rs:2:14 + | +1 | pub trait Trait { + | ----- this trait cannot be made into an object... +2 | async fn method(&self); + | ^^^^^^ ...because method `method` is `async` + = help: consider moving `method` to another trait diff --git a/tests/ui/send-not-implemented.stderr b/tests/ui/send-not-implemented.stderr index b8aedfd..7152b98 100644 --- a/tests/ui/send-not-implemented.stderr +++ b/tests/ui/send-not-implemented.stderr @@ -9,8 +9,7 @@ error: future cannot be sent between threads safely 12 | | } | |_____^ future created by async block is not `Send` | - = help: within `[async block@$DIR/tests/ui/send-not-implemented.rs:8:26: 12:6]`, the trait `Send` is not implemented for `MutexGuard<'_, ()>` - = note: consider using `std::sync::Arc<MutexGuard<'_, ()>>`; for more information visit <https://doc.rust-lang.org/book/ch16-03-shared-state.html> + = help: within `{async block@$DIR/tests/ui/send-not-implemented.rs:8:26: 12:6}`, the trait `Send` is not implemented for `MutexGuard<'_, ()>` note: future is not `Send` as this value is used across an await --> tests/ui/send-not-implemented.rs:11:13 | @@ -18,9 +17,7 @@ note: future is not `Send` as this value is used across an await | ------ has type `MutexGuard<'_, ()>` which is not `Send` 11 | f().await; | ^^^^^ await occurs here, with `_guard` maybe used later -12 | } - | - `_guard` is later dropped here - = note: required for the cast from `Pin<Box<[async block@$DIR/tests/ui/send-not-implemented.rs:8:26: 12:6]>>` to `Pin<Box<(dyn Future<Output = ()> + Send + 'async_trait)>>` + = note: required for the cast from `Pin<Box<{async block@$DIR/tests/ui/send-not-implemented.rs:8:26: 12:6}>>` to `Pin<Box<dyn Future<Output = ()> + Send>>` error: future cannot be sent between threads safely --> tests/ui/send-not-implemented.rs:14:38 @@ -34,8 +31,7 @@ error: future cannot be sent between threads safely 19 | | } | |_____^ future created by async block is not `Send` | - = help: within `[async block@$DIR/tests/ui/send-not-implemented.rs:14:38: 19:6]`, the trait `Send` is not implemented for `MutexGuard<'_, ()>` - = note: consider using `std::sync::Arc<MutexGuard<'_, ()>>`; for more information visit <https://doc.rust-lang.org/book/ch16-03-shared-state.html> + = help: within `{async block@$DIR/tests/ui/send-not-implemented.rs:14:38: 19:6}`, the trait `Send` is not implemented for `MutexGuard<'_, ()>` note: future is not `Send` as this value is used across an await --> tests/ui/send-not-implemented.rs:17:13 | @@ -43,7 +39,4 @@ note: future is not `Send` as this value is used across an await | ------ has type `MutexGuard<'_, ()>` which is not `Send` 17 | f().await; | ^^^^^ await occurs here, with `_guard` maybe used later -18 | true -19 | } - | - `_guard` is later dropped here - = note: required for the cast from `Pin<Box<[async block@$DIR/tests/ui/send-not-implemented.rs:14:38: 19:6]>>` to `Pin<Box<(dyn Future<Output = bool> + Send + 'async_trait)>>` + = note: required for the cast from `Pin<Box<{async block@$DIR/tests/ui/send-not-implemented.rs:14:38: 19:6}>>` to `Pin<Box<dyn Future<Output = bool> + Send>>` |