diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-05-10 07:02:15 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-05-10 07:02:15 +0000 |
commit | adc79426562fbb8dccf4d783f5c90a947f5b1cc5 (patch) | |
tree | 2a7bf8ed1294c37fec626fedb08d28701816964b | |
parent | a6d15f245027587e4a96e7613762efa09fc1c272 (diff) | |
parent | b3bef11cea56e2a4bf5310128d4b3e6b51e0707e (diff) | |
download | futures-core-android13-mainline-extservices-release.tar.gz |
Snap for 8564071 from b3bef11cea56e2a4bf5310128d4b3e6b51e0707e to mainline-extservices-releaseaml_ext_331814220aml_ext_331412000aml_ext_331312000aml_ext_331112010aml_ext_331012020android13-mainline-extservices-release
Change-Id: Idafb2fb7f845c4f411989a89b5f717efdaa242a9
-rw-r--r-- | .cargo_vcs_info.json | 7 | ||||
-rw-r--r-- | Android.bp | 30 | ||||
-rw-r--r-- | Cargo.toml | 24 | ||||
-rw-r--r-- | Cargo.toml.orig | 10 | ||||
-rw-r--r-- | METADATA | 8 | ||||
-rw-r--r-- | README.md | 23 | ||||
-rw-r--r-- | TEST_MAPPING | 52 | ||||
-rw-r--r-- | build.rs | 41 | ||||
-rw-r--r-- | cargo2android.json | 5 | ||||
-rw-r--r-- | no_atomic_cas.rs | 13 | ||||
-rw-r--r-- | src/future.rs | 10 | ||||
-rw-r--r-- | src/lib.rs | 29 | ||||
-rw-r--r-- | src/stream.rs | 43 | ||||
-rw-r--r-- | src/task/__internal/atomic_waker.rs | 19 | ||||
-rw-r--r-- | src/task/__internal/mod.rs | 4 | ||||
-rw-r--r-- | src/task/mod.rs | 2 | ||||
-rw-r--r-- | src/task/poll.rs | 11 |
17 files changed, 175 insertions, 156 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index f3ad3ab..724f674 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,6 @@ { "git": { - "sha1": "c91f8691672c7401b1923ab00bf138975c99391a" - } -} + "sha1": "fc1e3250219170e31cddb8857a276cba7dd08d44" + }, + "path_in_vcs": "futures-core" +}
\ No newline at end of file @@ -37,37 +37,12 @@ license { ], } -rust_defaults { - name: "futures-core_defaults", - crate_name: "futures_core", - srcs: ["src/lib.rs"], - test_suites: ["general-tests"], - auto_gen_config: true, - edition: "2018", - features: [ - "alloc", - "default", - "std", - ], -} - -rust_test_host { - name: "futures-core_host_test_src_lib", - defaults: ["futures-core_defaults"], - test_options: { - unit_test: true, - }, -} - -rust_test { - name: "futures-core_device_test_src_lib", - defaults: ["futures-core_defaults"], -} - rust_library { name: "libfutures_core", host_supported: true, crate_name: "futures_core", + cargo_env_compat: true, + cargo_pkg_version: "0.3.21", srcs: ["src/lib.rs"], edition: "2018", features: [ @@ -77,6 +52,7 @@ rust_library { ], apex_available: [ "//apex_available:platform", + "com.android.bluetooth", "com.android.resolv", "com.android.virt", ], @@ -3,26 +3,30 @@ # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies +# to registry (e.g., crates.io) dependencies. # -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. [package] edition = "2018" +rust-version = "1.36" name = "futures-core" -version = "0.3.13" -authors = ["Alex Crichton <alex@alexcrichton.com>"] -description = "The core traits and types in for the `futures` library.\n" +version = "0.3.21" +description = """ +The core traits and types in for the `futures` library. +""" homepage = "https://rust-lang.github.io/futures-rs" -documentation = "https://docs.rs/futures-core/0.3" license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/futures-rs" + [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] +rustdoc-args = [ + "--cfg", + "docsrs", +] [dependencies] diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 55601db..4a360f8 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,12 +1,11 @@ [package] name = "futures-core" +version = "0.3.21" edition = "2018" -version = "0.3.13" -authors = ["Alex Crichton <alex@alexcrichton.com>"] +rust-version = "1.36" license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/futures-rs" homepage = "https://rust-lang.github.io/futures-rs" -documentation = "https://docs.rs/futures-core/0.3" description = """ The core traits and types in for the `futures` library. """ @@ -16,9 +15,8 @@ default = ["std"] std = ["alloc"] alloc = [] -# Unstable features -# These features are outside of the normal semver guarantees and require the -# `unstable` feature as an explicit opt-in to unstable API. +# These features are no longer used. +# TODO: remove in the next major version. unstable = [] cfg-target-has-atomic = [] @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/futures-core/futures-core-0.3.13.crate" + value: "https://static.crates.io/crates/futures-core/futures-core-0.3.21.crate" } - version: "0.3.13" + version: "0.3.21" license_type: NOTICE last_upgrade_date { - year: 2021 + year: 2022 month: 3 - day: 4 + day: 1 } } diff --git a/README.md b/README.md new file mode 100644 index 0000000..96e0e06 --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +# futures-core + +The core traits and types in for the `futures` library. + +## Usage + +Add this to your `Cargo.toml`: + +```toml +[dependencies] +futures-core = "0.3" +``` + +The current `futures-core` requires Rust 1.36 or later. + +## License + +Licensed under either of [Apache License, Version 2.0](LICENSE-APACHE) or +[MIT license](LICENSE-MIT) at your option. + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in the work by you, as defined in the Apache-2.0 license, shall +be dual licensed as above, without any additional terms or conditions. diff --git a/TEST_MAPPING b/TEST_MAPPING index 8052406..5ef61de 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -1,59 +1,45 @@ // Generated by update_crate_tests.py for tests that depend on this crate. { - "presubmit": [ - { - "name": "anyhow_device_test_tests_test_repr" - }, - { - "name": "anyhow_device_test_tests_test_convert" - }, - { - "name": "anyhow_device_test_src_lib" - }, - { - "name": "anyhow_device_test_tests_test_chain" - }, + "imports": [ { - "name": "anyhow_device_test_tests_test_boxed" + "path": "external/rust/crates/anyhow" }, { - "name": "tokio-test_device_test_tests_macros" + "path": "external/rust/crates/futures-util" }, { - "name": "tokio-test_device_test_tests_block_on" + "path": "external/rust/crates/tokio" }, { - "name": "anyhow_device_test_tests_test_downcast" - }, - { - "name": "anyhow_device_test_tests_test_context" - }, - { - "name": "futures-core_device_test_src_lib" - }, + "path": "external/rust/crates/tokio-test" + } + ], + "presubmit": [ { - "name": "futures-util_device_test_src_lib" + "name": "ZipFuseTest" }, { - "name": "tokio-test_device_test_tests_io" + "name": "authfs_device_test_src_lib" }, { - "name": "tokio-test_device_test_src_lib" + "name": "doh_unit_test" }, { - "name": "anyhow_device_test_tests_test_macros" - }, + "name": "virtualizationservice_device_test" + } + ], + "presubmit-rust": [ { - "name": "anyhow_device_test_tests_test_ffi" + "name": "ZipFuseTest" }, { - "name": "anyhow_device_test_tests_test_fmt" + "name": "authfs_device_test_src_lib" }, { - "name": "anyhow_device_test_tests_test_autotrait" + "name": "doh_unit_test" }, { - "name": "anyhow_device_test_tests_test_source" + "name": "virtualizationservice_device_test" } ] } diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..05e0496 --- /dev/null +++ b/build.rs @@ -0,0 +1,41 @@ +// The rustc-cfg listed below are considered public API, but it is *unstable* +// and outside of the normal semver guarantees: +// +// - `futures_no_atomic_cas` +// Assume the target does *not* support atomic CAS operations. +// This is usually detected automatically by the build script, but you may +// need to enable it manually when building for custom targets or using +// non-cargo build systems that don't run the build script. +// +// With the exceptions mentioned above, the rustc-cfg emitted by the build +// script are *not* public API. + +#![warn(rust_2018_idioms, single_use_lifetimes)] + +use std::env; + +include!("no_atomic_cas.rs"); + +fn main() { + let target = match env::var("TARGET") { + Ok(target) => target, + Err(e) => { + println!( + "cargo:warning={}: unable to get TARGET environment variable: {}", + env!("CARGO_PKG_NAME"), + e + ); + return; + } + }; + + // Note that this is `no_*`, not `has_*`. This allows treating + // `cfg(target_has_atomic = "ptr")` as true when the build script doesn't + // run. This is needed for compatibility with non-cargo build systems that + // don't run the build script. + if NO_ATOMIC_CAS.contains(&&*target) { + println!("cargo:rustc-cfg=futures_no_atomic_cas"); + } + + println!("cargo:rerun-if-changed=no_atomic_cas.rs"); +} diff --git a/cargo2android.json b/cargo2android.json index 44e747c..5b266a6 100644 --- a/cargo2android.json +++ b/cargo2android.json @@ -1,12 +1,13 @@ { "apex-available": [ "//apex_available:platform", + "com.android.bluetooth", "com.android.resolv", "com.android.virt" ], - "min_sdk_version": "29", "dependencies": true, "device": true, + "min-sdk-version": "29", "run": true, "tests": true -}
\ No newline at end of file +} diff --git a/no_atomic_cas.rs b/no_atomic_cas.rs new file mode 100644 index 0000000..9b05d4b --- /dev/null +++ b/no_atomic_cas.rs @@ -0,0 +1,13 @@ +// This file is @generated by no_atomic_cas.sh. +// It is not intended for manual editing. + +const NO_ATOMIC_CAS: &[&str] = &[ + "avr-unknown-gnu-atmega328", + "bpfeb-unknown-none", + "bpfel-unknown-none", + "msp430-none-elf", + "riscv32i-unknown-none-elf", + "riscv32imc-unknown-none-elf", + "thumbv4t-none-eabi", + "thumbv6m-none-eabi", +]; diff --git a/src/future.rs b/src/future.rs index d9327c0..7540cd0 100644 --- a/src/future.rs +++ b/src/future.rs @@ -67,14 +67,12 @@ pub trait TryFuture: Future + private_try_future::Sealed { /// This method is a stopgap for a compiler limitation that prevents us from /// directly inheriting from the `Future` trait; in the future it won't be /// needed. - fn try_poll( - self: Pin<&mut Self>, - cx: &mut Context<'_>, - ) -> Poll<Result<Self::Ok, Self::Error>>; + fn try_poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<Self::Ok, Self::Error>>; } impl<F, T, E> TryFuture for F - where F: ?Sized + Future<Output = Result<T, E>> +where + F: ?Sized + Future<Output = Result<T, E>>, { type Ok = T; type Error = E; @@ -87,8 +85,8 @@ impl<F, T, E> TryFuture for F #[cfg(feature = "alloc")] mod if_alloc { - use alloc::boxed::Box; use super::*; + use alloc::boxed::Box; impl<F: FusedFuture + ?Sized + Unpin> FusedFuture for Box<F> { fn is_terminated(&self) -> bool { @@ -1,32 +1,27 @@ //! Core traits and types for asynchronous operations in Rust. -#![cfg_attr(feature = "cfg-target-has-atomic", feature(cfg_target_has_atomic))] - #![cfg_attr(not(feature = "std"), no_std)] - -#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms, unreachable_pub)] +#![warn(missing_debug_implementations, missing_docs, rust_2018_idioms, unreachable_pub)] // It cannot be included in the published code because this lints have false positives in the minimum required version. #![cfg_attr(test, warn(single_use_lifetimes))] -#![warn(clippy::all)] -#![doc(test(attr(deny(warnings), allow(dead_code, unused_assignments, unused_variables))))] - -#[cfg(all(feature = "cfg-target-has-atomic", not(feature = "unstable")))] -compile_error!("The `cfg-target-has-atomic` feature requires the `unstable` feature as an explicit opt-in to unstable features"); +#![doc(test( + no_crate_inject, + attr( + deny(warnings, rust_2018_idioms, single_use_lifetimes), + allow(dead_code, unused_assignments, unused_variables) + ) +))] #[cfg(feature = "alloc")] extern crate alloc; pub mod future; -#[doc(hidden)] pub use self::future::{Future, FusedFuture, TryFuture}; +#[doc(no_inline)] +pub use self::future::{FusedFuture, Future, TryFuture}; pub mod stream; -#[doc(hidden)] pub use self::stream::{Stream, FusedStream, TryStream}; +#[doc(no_inline)] +pub use self::stream::{FusedStream, Stream, TryStream}; #[macro_use] pub mod task; - -// Not public API. -#[doc(hidden)] -pub mod __private { - pub use core::task::Poll; -} diff --git a/src/stream.rs b/src/stream.rs index 4a13e3b..ad5350b 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -63,10 +63,7 @@ pub trait Stream { /// calls. /// /// [`fuse`]: https://docs.rs/futures/0.3/futures/stream/trait.StreamExt.html#method.fuse - fn poll_next( - self: Pin<&mut Self>, - cx: &mut Context<'_>, - ) -> Poll<Option<Self::Item>>; + fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>>; /// Returns the bounds on the remaining length of the stream. /// @@ -103,10 +100,7 @@ pub trait Stream { impl<S: ?Sized + Stream + Unpin> Stream for &mut S { type Item = S::Item; - fn poll_next( - mut self: Pin<&mut Self>, - cx: &mut Context<'_>, - ) -> Poll<Option<Self::Item>> { + fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { S::poll_next(Pin::new(&mut **self), cx) } @@ -122,10 +116,7 @@ where { type Item = <P::Target as Stream>::Item; - fn poll_next( - self: Pin<&mut Self>, - cx: &mut Context<'_>, - ) -> Poll<Option<Self::Item>> { + fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { self.get_mut().as_mut().poll_next(cx) } @@ -185,35 +176,36 @@ pub trait TryStream: Stream + private_try_stream::Sealed { /// This method is a stopgap for a compiler limitation that prevents us from /// directly inheriting from the `Stream` trait; in the future it won't be /// needed. - fn try_poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) - -> Poll<Option<Result<Self::Ok, Self::Error>>>; + fn try_poll_next( + self: Pin<&mut Self>, + cx: &mut Context<'_>, + ) -> Poll<Option<Result<Self::Ok, Self::Error>>>; } impl<S, T, E> TryStream for S - where S: ?Sized + Stream<Item = Result<T, E>> +where + S: ?Sized + Stream<Item = Result<T, E>>, { type Ok = T; type Error = E; - fn try_poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) - -> Poll<Option<Result<Self::Ok, Self::Error>>> - { + fn try_poll_next( + self: Pin<&mut Self>, + cx: &mut Context<'_>, + ) -> Poll<Option<Result<Self::Ok, Self::Error>>> { self.poll_next(cx) } } #[cfg(feature = "alloc")] mod if_alloc { - use alloc::boxed::Box; use super::*; + use alloc::boxed::Box; impl<S: ?Sized + Stream + Unpin> Stream for Box<S> { type Item = S::Item; - fn poll_next( - mut self: Pin<&mut Self>, - cx: &mut Context<'_>, - ) -> Poll<Option<Self::Item>> { + fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { Pin::new(&mut **self).poll_next(cx) } @@ -226,10 +218,7 @@ mod if_alloc { impl<S: Stream> Stream for std::panic::AssertUnwindSafe<S> { type Item = S::Item; - fn poll_next( - self: Pin<&mut Self>, - cx: &mut Context<'_>, - ) -> Poll<Option<S::Item>> { + fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<S::Item>> { unsafe { self.map_unchecked_mut(|x| &mut x.0) }.poll_next(cx) } diff --git a/src/task/__internal/atomic_waker.rs b/src/task/__internal/atomic_waker.rs index 213355b..d49d043 100644 --- a/src/task/__internal/atomic_waker.rs +++ b/src/task/__internal/atomic_waker.rs @@ -1,7 +1,7 @@ use core::cell::UnsafeCell; use core::fmt; use core::sync::atomic::AtomicUsize; -use core::sync::atomic::Ordering::{Acquire, Release, AcqRel}; +use core::sync::atomic::Ordering::{AcqRel, Acquire, Release}; use core::task::Waker; /// A synchronization primitive for task wakeup. @@ -202,10 +202,7 @@ impl AtomicWaker { trait AssertSync: Sync {} impl AssertSync for Waker {} - Self { - state: AtomicUsize::new(WAITING), - waker: UnsafeCell::new(None), - } + Self { state: AtomicUsize::new(WAITING), waker: UnsafeCell::new(None) } } /// Registers the waker to be notified on calls to `wake`. @@ -279,8 +276,7 @@ impl AtomicWaker { // nothing to acquire, only release. In case of concurrent // wakers, we need to acquire their releases, so success needs // to do both. - let res = self.state.compare_exchange( - REGISTERING, WAITING, AcqRel, Acquire); + let res = self.state.compare_exchange(REGISTERING, WAITING, AcqRel, Acquire); match res { Ok(_) => { @@ -344,9 +340,7 @@ impl AtomicWaker { // // We just want to maintain memory safety. It is ok to drop the // call to `register`. - debug_assert!( - state == REGISTERING || - state == REGISTERING | WAKING); + debug_assert!(state == REGISTERING || state == REGISTERING | WAKING); } } } @@ -391,9 +385,8 @@ impl AtomicWaker { // not. // debug_assert!( - state == REGISTERING || - state == REGISTERING | WAKING || - state == WAKING); + state == REGISTERING || state == REGISTERING | WAKING || state == WAKING + ); None } } diff --git a/src/task/__internal/mod.rs b/src/task/__internal/mod.rs index 77e3678..c902eb4 100644 --- a/src/task/__internal/mod.rs +++ b/src/task/__internal/mod.rs @@ -1,4 +1,4 @@ -#[cfg_attr(feature = "cfg-target-has-atomic", cfg(target_has_atomic = "ptr"))] +#[cfg(not(futures_no_atomic_cas))] mod atomic_waker; -#[cfg_attr(feature = "cfg-target-has-atomic", cfg(target_has_atomic = "ptr"))] +#[cfg(not(futures_no_atomic_cas))] pub use self::atomic_waker::AtomicWaker; diff --git a/src/task/mod.rs b/src/task/mod.rs index f945d5d..19e4eae 100644 --- a/src/task/mod.rs +++ b/src/task/mod.rs @@ -7,4 +7,4 @@ mod poll; pub mod __internal; #[doc(no_inline)] -pub use core::task::{Context, Poll, Waker, RawWaker, RawWakerVTable}; +pub use core::task::{Context, Poll, RawWaker, RawWakerVTable, Waker}; diff --git a/src/task/poll.rs b/src/task/poll.rs index 8fe294c..607e78e 100644 --- a/src/task/poll.rs +++ b/src/task/poll.rs @@ -3,9 +3,10 @@ /// This macro bakes in propagation of `Pending` signals by returning early. #[macro_export] macro_rules! ready { - ($e:expr $(,)?) => (match $e { - $crate::__private::Poll::Ready(t) => t, - $crate::__private::Poll::Pending => - return $crate::__private::Poll::Pending, - }) + ($e:expr $(,)?) => { + match $e { + $crate::task::Poll::Ready(t) => t, + $crate::task::Poll::Pending => return $crate::task::Poll::Pending, + } + }; } |