From a414c4bb81da10b25d021b7eb79af4e37a1066aa Mon Sep 17 00:00:00 2001 From: Jeff Vander Stoep Date: Fri, 24 Nov 2023 15:39:09 +0100 Subject: Upgrade async-trait to 0.1.74 This project was upgraded with external_updater. Usage: tools/external_updater/updater.sh update rust/crates/async-trait For more info, check https://cs.android.com/android/platform/superproject/+/main:tools/external_updater/README.md Test: TreeHugger Change-Id: I4c65a329a30b54d2e03ded328862f208d17bca10 --- .cargo_vcs_info.json | 2 +- .github/workflows/ci.yml | 24 +++++++++++++++++++----- Android.bp | 2 +- Cargo.toml | 2 +- Cargo.toml.orig | 2 +- METADATA | 22 +++++++++++----------- build.rs | 6 +++++- src/lib.rs | 7 ++++--- tests/ui/consider-restricting.stderr | 6 ++---- tests/ui/no-attribute-macro.rs | 13 +++++++++++++ tests/ui/no-attribute-macro.stderr | 14 ++++++++++++++ tests/ui/send-not-implemented.stderr | 15 ++++----------- 12 files changed, 76 insertions(+), 39 deletions(-) create mode 100644 tests/ui/no-attribute-macro.rs create mode 100644 tests/ui/no-attribute-macro.stderr 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 diff --git a/Android.bp b/Android.bp index 7533cd8..4ed9317 100644 --- a/Android.bp +++ b/Android.bp @@ -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: [ diff --git a/Cargo.toml b/Cargo.toml index b8058ec..0bb7764 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ edition = "2021" rust-version = "1.56" name = "async-trait" -version = "0.1.73" +version = "0.1.74" authors = ["David Tolnay "] 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 "] categories = ["asynchronous", "no-std"] description = "Type erasure for async trait methods" diff --git a/METADATA b/METADATA index 403a480..2d7b381 100644 --- a/METADATA +++ b/METADATA @@ -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" } } diff --git a/build.rs b/build.rs index d7f6b15..f25fb0a 100644 --- a/build.rs +++ b/build.rs @@ -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 { diff --git a/src/lib.rs b/src/lib.rs index e35dd03..435d508 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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(&self, url: T) {} | ^^ future created by async block is not `Send` | - = note: consider using `std::sync::Arc`; for more information visit note: captured value is not `Send` --> tests/ui/consider-restricting.rs:16:41 | 16 | async fn publish(&self, url: T) {} | ^^^ has type `T` which is not `Send` - = note: required for the cast from `Pin>` to `Pin + Send + 'async_trait)>>` + = note: required for the cast from `Pin>` to `Pin + Send + 'async_trait)>>` help: consider further restricting this bound | 16 | async fn publish(&self, url: T) {} @@ -22,13 +21,12 @@ error: future cannot be sent between threads safely 23 | async fn publish(&self, url: T) {} | ^^ future created by async block is not `Send` | - = note: consider using `std::sync::Arc`; for more information visit note: captured value is not `Send` --> tests/ui/consider-restricting.rs:23:32 | 23 | async fn publish(&self, url: T) {} | ^^^ has type `T` which is not `Send` - = note: required for the cast from `Pin>` to `Pin + Send + 'async_trait)>>` + = note: required for the cast from `Pin>` to `Pin + Send + 'async_trait)>>` help: consider further restricting this bound | 23 | async fn publish(&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 + --> 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>`; for more information visit + = 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>` to `Pin + Send + 'async_trait)>>` + = note: required for the cast from `Pin>` to `Pin + 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>`; for more information visit + = 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>` to `Pin + Send + 'async_trait)>>` + = note: required for the cast from `Pin>` to `Pin + Send>>` -- cgit v1.2.3