aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Vander Stoep <jeffv@google.com>2023-11-24 17:38:24 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-11-24 17:38:24 +0000
commit3a0f1cd40b916f0f9d3646e74d41a6c78453d1f9 (patch)
tree5f68104e9962a2fb34e1ce6de499f96278355ff1
parentd302d7e8b3fe8ff0927cd29b6efb586a72d4ee3e (diff)
parent31a84d70ece810214648e28dee92b7e41354cd8a (diff)
downloadasync-trait-3a0f1cd40b916f0f9d3646e74d41a6c78453d1f9.tar.gz
Upgrade async-trait to 0.1.74 am: a414c4bb81 am: fe8a188ce0 am: 31a84d70ec
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/async-trait/+/2846255 Change-Id: Icbc1ffcd99eb66e092e68490b81ab1aebbc37cc3 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--.cargo_vcs_info.json2
-rw-r--r--.github/workflows/ci.yml24
-rw-r--r--Android.bp2
-rw-r--r--Cargo.toml2
-rw-r--r--Cargo.toml.orig2
-rw-r--r--METADATA22
-rw-r--r--build.rs6
-rw-r--r--src/lib.rs7
-rw-r--r--tests/ui/consider-restricting.stderr6
-rw-r--r--tests/ui/no-attribute-macro.rs13
-rw-r--r--tests/ui/no-attribute-macro.stderr14
-rw-r--r--tests/ui/send-not-implemented.stderr15
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
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 <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"
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<u32> {
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<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>>`