Skip to content

0.3 backports #2466

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jul 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 41 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,48 @@ defaults:

jobs:
test:
name: cargo +${{ matrix.rust }} test (${{ matrix.os }})
name: cargo test (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
rust:
- nightly
os:
- ubuntu-latest
- macos-latest
- windows-latest
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Install Rust
# --no-self-update is necessary because the windows environment cannot self-update rustup.exe.
run: rustup update ${{ matrix.rust }} --no-self-update && rustup default ${{ matrix.rust }}
run: rustup update nightly --no-self-update && rustup default nightly
- run: cargo test --workspace --all-features
- run: cargo test --workspace --all-features --release

cross:
name: cross test --target ${{ matrix.target }}
strategy:
fail-fast: false
matrix:
target:
- i686-unknown-linux-gnu
- aarch64-unknown-linux-gnu
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Rust
run: rustup update nightly && rustup default nightly
- run: cargo install cross
- run: cross test --target ${{ matrix.target }} --workspace --all-features
- run: cross test --target ${{ matrix.target }} --workspace --all-features --release
# TODO: https://github.com/rust-lang/futures-rs/issues/2451
if: matrix.target != 'aarch64-unknown-linux-gnu'

core-msrv:
name: cargo +${{ matrix.rust }} build (futures-{core, io, sink, task, channel})
name: cargo +${{ matrix.rust }} build (futures-{core, io, sink, task})
strategy:
matrix:
rust:
# This is the minimum Rust version supported by futures-core, futures-io, futures-sink, futures-task, futures-channel.
# This is the minimum Rust version supported by futures-core, futures-io, futures-sink, futures-task.
# When updating this, the reminder to update the minimum required version in .clippy.toml.
- 1.36.0
runs-on: ubuntu-latest
Expand All @@ -58,22 +76,22 @@ jobs:
# Check no-default-features
- run: |
cargo hack build --workspace --ignore-private --no-default-features \
--exclude futures --exclude futures-util --exclude futures-macro --exclude futures-executor --exclude futures-test
--exclude futures --exclude futures-util --exclude futures-macro --exclude futures-executor --exclude futures-channel --exclude futures-test
# Check alloc feature
- run: |
cargo hack build --workspace --ignore-private --no-default-features --features alloc --ignore-unknown-features \
--exclude futures --exclude futures-util --exclude futures-macro --exclude futures-executor --exclude futures-test
--exclude futures --exclude futures-util --exclude futures-macro --exclude futures-executor --exclude futures-channel --exclude futures-test
# Check std feature
- run: |
cargo hack build --workspace --ignore-private --no-default-features --features std \
--exclude futures --exclude futures-util --exclude futures-macro --exclude futures-executor --exclude futures-test
--exclude futures --exclude futures-util --exclude futures-macro --exclude futures-executor --exclude futures-channel --exclude futures-test

util-msrv:
name: cargo +${{ matrix.rust }} build
strategy:
matrix:
rust:
# This is the minimum Rust version supported by futures, futures-util, futures-macro, futures-executor, futures-test.
# This is the minimum Rust version supported by futures, futures-util, futures-macro, futures-executor, futures-channel, futures-test.
# When updating this, the reminder to update the minimum required version in README.md.
- 1.41.0
runs-on: ubuntu-latest
Expand All @@ -100,6 +118,7 @@ jobs:
build:
name: cargo +${{ matrix.rust }} build
strategy:
fail-fast: false
matrix:
rust:
- stable
Expand Down Expand Up @@ -130,10 +149,13 @@ jobs:
no-std:
name: cargo build --target ${{ matrix.target }}
strategy:
fail-fast: false
matrix:
# thumbv7m-none-eabi supports atomic CAS.
# thumbv6m-none-eabi supports atomic, but not atomic CAS.
target:
- thumbv6m-none-eabi
- thumbv7m-none-eabi
- thumbv6m-none-eabi
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -210,6 +232,7 @@ jobs:
san:
name: cargo test -Z sanitizer=${{ matrix.sanitizer }}
strategy:
fail-fast: false
matrix:
sanitizer:
- address
Expand All @@ -235,21 +258,17 @@ jobs:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - name: Install Rust and Clippy
# run: |
# toolchain=nightly-$(curl -sSf https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/clippy)
# rustup set profile minimal
# rustup default "$toolchain"
# rustup component add clippy
# - name: Install Rust
# run: rustup toolchain install nightly --component clippy && rustup default nightly
# - run: cargo clippy --workspace --all-features --all-targets

fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Rust
run: rustup update stable && rustup default stable
- run: tools/fmt.sh
run: rustup update stable
- run: cargo fmt --all -- --check

docs:
name: cargo doc
Expand Down
12 changes: 6 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
* Fixed bug with zero-size buffers in vectored IO (#1998)
* `AtomicWaker::new()` is now `const fn` (#2007)
* Fixed bug between threadpool and user park/unparking (#2010)
* Added `stream::Peakable::peek` (#2021)
* Added `stream::Peekable::peek` (#2021)
* Added `StreamExt::scan` (#2044)
* Added impl of `AsyncRead`/`Write` for `BufReader`/`Writer` (#2033)
* Added impl of `Spawn` and `LocalSpawn` for `Arc<impl Spawn` and `Rc<impl Spawn>` (#2039)
Expand Down Expand Up @@ -238,7 +238,7 @@
# 0.3.0-alpha.14 - 2019-4-15
* Updated to new nightly `futures_api`.
* Changed `Forward` combinator to drop sink after completion, and allow `!Unpin` `Sink`s.
* Added 0.1 <-> 0.3 compatability shim for `Sink`s.
* Added 0.1 <-> 0.3 compatibility shim for `Sink`s.
* Changed `Sink::Item` to a generic parameter `Sink<Item>`, allowing `Sink`s to accept
multiple different types, including types containing references.
* Changed `AsyncRead` and `AsyncWrite` to take `Pin<&mut Self>` rather than `&mut self`.
Expand Down Expand Up @@ -313,8 +313,8 @@
* `StreamExt::boxed` combinator
* Unsoundness fix for `FuturesUnordered`
* `StreamObj` (similar to `FutureObj`)
* Code examples for compatiblity layer functions
* Use cargo create renaming feature to import `futures@0.1` for compatiblily layer
* Code examples for compatibility layer functions
* Use cargo create renaming feature to import `futures@0.1` for compatibility layer
* Import pinning APIs from `core::pin`
* Run Clippy in CI only when it is available

Expand All @@ -338,7 +338,7 @@

# 0.3.0-alpha.2 - 2018-07-30
* The changelog is back!
* Compatiblity with futures API in latest nightly
* Compatibility with futures API in latest nightly
* Code examples and doc improvements
- IO: Methods of traits `AsyncReadExt`, `AsyncWriteExt`
- Future:
Expand All @@ -360,7 +360,7 @@
* We now use the unstable `use_extern_macros` feature for macro reexports
* CI improvements: Named CI jobs, tests are now run on macOS and Linux, the docs are generated and Clippy needs to pass
* `#[deny(warnings)]` was removed from all crates and is now only enforced in the CI
* We now have a naming convention for type paramters: `Fut` future, `F` function, `St` stream, `Si` sink, `S` sink & stream, `R` reader, `W` writer, `T` value, `E` error
* We now have a naming convention for type parameters: `Fut` future, `F` function, `St` stream, `Si` sink, `S` sink & stream, `R` reader, `W` writer, `T` value, `E` error
* "Task" is now defined as our term for "lightweight thread". The code of the executors and `FuturesUnordered` was refactored to align with this definition.

# 0.3.0-alpha.1 - 2018-07-19
Expand Down
5 changes: 5 additions & 0 deletions ci/no_atomic_cas.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/bin/bash

# Update the list of targets that do not support atomic CAS operations.
#
# Usage:
# ./ci/no_atomic_cas.sh

set -euo pipefail
IFS=$'\n\t'

Expand Down
2 changes: 1 addition & 1 deletion examples/functional/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fn main() {
};

// Actually execute the above future, which will invoke Future::poll and
// subsequenty chain appropriate Future::poll and methods needing executors
// subsequently chain appropriate Future::poll and methods needing executors
// to drive all futures. Eventually fut_values will be driven to completion.
let values: Vec<i32> = executor::block_on(fut_values);

Expand Down
2 changes: 1 addition & 1 deletion examples/imperative/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn main() {
};

// Actually execute the above future, which will invoke Future::poll and
// subsequenty chain appropriate Future::poll and methods needing executors
// subsequently chain appropriate Future::poll and methods needing executors
// to drive all futures. Eventually fut_values will be driven to completion.
let values: Vec<i32> = executor::block_on(fut_values);

Expand Down
2 changes: 1 addition & 1 deletion futures-channel/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ include!("no_atomic_cas.rs");
// and outside of the normal semver guarantees:
//
// - `futures_no_atomic_cas`
// Assume the target does not have atomic CAS (compare-and-swap).
// 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.
Expand Down
48 changes: 26 additions & 22 deletions futures-channel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,31 @@
//! library is activated, and it is activated by default.

#![cfg_attr(not(feature = "std"), no_std)]
#![warn(missing_docs, missing_debug_implementations, 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))))]
#![warn(
missing_debug_implementations,
missing_docs,
rust_2018_idioms,
single_use_lifetimes,
unreachable_pub
)]
#![doc(test(
no_crate_inject,
attr(
deny(warnings, rust_2018_idioms, single_use_lifetimes),
allow(dead_code, unused_assignments, unused_variables)
)
))]

macro_rules! cfg_target_has_atomic {
($($item:item)*) => {$(
#[cfg(not(futures_no_atomic_cas))]
$item
)*};
}
#[cfg(not(futures_no_atomic_cas))]
#[cfg(feature = "alloc")]
extern crate alloc;

cfg_target_has_atomic! {
#[cfg(feature = "alloc")]
extern crate alloc;

#[cfg(feature = "alloc")]
mod lock;
#[cfg(feature = "std")]
pub mod mpsc;
#[cfg(feature = "alloc")]
pub mod oneshot;
}
#[cfg(not(futures_no_atomic_cas))]
#[cfg(feature = "alloc")]
mod lock;
#[cfg(not(futures_no_atomic_cas))]
#[cfg(feature = "std")]
pub mod mpsc;
#[cfg(not(futures_no_atomic_cas))]
#[cfg(feature = "alloc")]
pub mod oneshot;
3 changes: 1 addition & 2 deletions futures-channel/src/mpsc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,9 +510,8 @@ impl<T> BoundedSenderInner<T> {

// Do the send without failing.
// Can be called only by bounded sender.
#[allow(clippy::debug_assert_with_mut_call)]
fn do_send_b(&mut self, msg: T) -> Result<(), TrySendError<T>> {
// Anyone callig do_send *should* make sure there is room first,
// Anyone calling do_send *should* make sure there is room first,
// but assert here for tests as a sanity check.
debug_assert!(self.poll_unparked(None).is_ready());

Expand Down
2 changes: 1 addition & 1 deletion futures-core/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ include!("no_atomic_cas.rs");
// and outside of the normal semver guarantees:
//
// - `futures_no_atomic_cas`
// Assume the target does not have atomic CAS (compare-and-swap).
// 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.
Expand Down
17 changes: 8 additions & 9 deletions futures-core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
//! Core traits and types for asynchronous operations in Rust.

#![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))))]
#![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;
Expand All @@ -20,9 +25,3 @@ 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;
}
4 changes: 2 additions & 2 deletions futures-core/src/task/poll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
macro_rules! ready {
($e:expr $(,)?) => {
match $e {
$crate::__private::Poll::Ready(t) => t,
$crate::__private::Poll::Pending => return $crate::__private::Poll::Pending,
$crate::task::Poll::Ready(t) => t,
$crate::task::Poll::Pending => return $crate::task::Poll::Pending,
}
};
}
19 changes: 14 additions & 5 deletions futures-executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,20 @@
//! [`spawn_local_obj`]: https://docs.rs/futures/0.3/futures/task/trait.LocalSpawn.html#tymethod.spawn_local_obj

#![cfg_attr(not(feature = "std"), no_std)]
#![warn(missing_docs, missing_debug_implementations, 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))))]
#![warn(
missing_debug_implementations,
missing_docs,
rust_2018_idioms,
single_use_lifetimes,
unreachable_pub
)]
#![doc(test(
no_crate_inject,
attr(
deny(warnings, rust_2018_idioms, single_use_lifetimes),
allow(dead_code, unused_assignments, unused_variables)
)
))]
#![cfg_attr(docsrs, feature(doc_cfg))]

#[cfg(feature = "std")]
Expand Down
4 changes: 2 additions & 2 deletions futures-executor/src/thread_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ impl ThreadPoolBuilder {
/// Execute closure `f` just prior to shutting down each worker thread.
///
/// This hook is intended for bookkeeping and monitoring.
/// The closure `f` will be dropped after the `builder` is droppped
/// The closure `f` will be dropped after the `builder` is dropped
/// and all threads in the pool have executed it.
///
/// The closure provided will receive an index corresponding to the worker
Expand Down Expand Up @@ -367,7 +367,7 @@ mod tests {
.create()
.unwrap();

// After ThreadPoolBuilder is deconstructed, the tx should be droped
// After ThreadPoolBuilder is deconstructed, the tx should be dropped
// so that we can use rx as an iterator.
let count = rx.into_iter().count();
assert_eq!(count, 2);
Expand Down
2 changes: 1 addition & 1 deletion futures-executor/tests/local_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ fn tasks_are_scheduled_fairly() {
}

// Tests that the use of park/unpark in user-code has no
// effect on the expected behaviour of the executor.
// effect on the expected behavior of the executor.
#[test]
fn park_unpark_independence() {
let mut done = false;
Expand Down
Loading