From b2ff9137fa3b83ca4baf2594081da7f03c3faa6a Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Tue, 11 Jul 2023 01:33:27 +0900 Subject: [PATCH 1/4] ci: Fix MSRV build ``` error package `log v0.4.19` cannot be built because it requires rustc 1.60.0 or newer, while the currently active rustc version is 1.56.1 ``` --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a20945b66..3c43a93a2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -127,7 +127,8 @@ jobs: # Check std feature - run: cargo hack build --workspace --ignore-private --no-default-features --features std --ignore-unknown-features # Check compat feature (futures, futures-util) - - run: cargo hack build -p futures -p futures-util --no-default-features --features std,io-compat + # Exclude io-compat feature because the MSRV when it is enabled depends on the MSRV of tokio 0.1. + - run: cargo hack build -p futures -p futures-util --no-default-features --features std,compat # Check thread-pool feature (futures, futures-executor) - run: cargo hack build -p futures -p futures-executor --no-default-features --features std,thread-pool From 7e83347d3b81827053364ac2916f68c2323b8481 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Tue, 11 Jul 2023 01:37:42 +0900 Subject: [PATCH 2/4] Fix build error with -Z minimal-versions ``` error[E0635]: unknown feature `proc_macro_span_shrink` --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.52/src/lib.rs:92:30 | 92 | feature(proc_macro_span, proc_macro_span_shrink) | ^^^^^^^^^^^^^^^^^^^^^^ ``` --- .github/workflows/ci.yml | 9 ++++----- futures-macro/Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3c43a93a2..e9fb2b35c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -152,7 +152,7 @@ jobs: - run: cargo build --tests --features default,thread-pool,io-compat --manifest-path futures/Cargo.toml minimal-versions: - name: cargo build -Z minimal-versions + name: cargo minimal-versions build runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -160,10 +160,9 @@ jobs: run: rustup update nightly && rustup default nightly - name: Install cargo-hack uses: taiki-e/install-action@cargo-hack - # remove dev-dependencies to avoid https://github.com/rust-lang/cargo/issues/4866 - - run: cargo hack --remove-dev-deps --workspace - - run: cargo update -Z minimal-versions - - run: cargo build --workspace --all-features + - name: Install cargo-minimal-versions + uses: taiki-e/install-action@cargo-minimal-versions + - run: cargo minimal-versions build --workspace --ignore-private --all-features no-std: name: cargo build --target ${{ matrix.target }} diff --git a/futures-macro/Cargo.toml b/futures-macro/Cargo.toml index 54bd533c8..c5c85f1d2 100644 --- a/futures-macro/Cargo.toml +++ b/futures-macro/Cargo.toml @@ -16,6 +16,6 @@ proc-macro = true [features] [dependencies] -proc-macro2 = "1.0" +proc-macro2 = "1.0.60" quote = "1.0" syn = { version = "2.0.8", features = ["full"] } From 1425bff9be5ddb109ecd749e42c33fa1ef280516 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Tue, 11 Jul 2023 01:39:04 +0900 Subject: [PATCH 3/4] Ignore buggy clippy::arc_with_non_send_sync lint ``` error: usage of `Arc` where `T` is not `Send` or `Sync` --> futures-channel/src/mpsc/mod.rs:348:17 | 348 | let inner = Arc::new(BoundedInner { | _________________^ 349 | | buffer, 350 | | state: AtomicUsize::new(INIT_STATE), 351 | | message_queue: Queue::new(), ... | 354 | | recv_task: AtomicWaker::new(), 355 | | }); | |______^ | = help: consider using `Rc` instead or wrapping `T` in a std::sync type like `Mutex` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#arc_with_non_send_sync = note: `#[deny(clippy::arc_with_non_send_sync)]` on by default error: usage of `Arc` where `T` is not `Send` or `Sync` --> futures-channel/src/mpsc/mod.rs:379:17 | 379 | let inner = Arc::new(UnboundedInner { | _________________^ 380 | | state: AtomicUsize::new(INIT_STATE), 381 | | message_queue: Queue::new(), 382 | | num_senders: AtomicUsize::new(1), 383 | | recv_task: AtomicWaker::new(), 384 | | }); | |______^ | = help: consider using `Rc` instead or wrapping `T` in a std::sync type like `Mutex` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#arc_with_non_send_sync error: usage of `Arc` where `T` is not `Send` or `Sync` --> futures-channel/src/oneshot.rs:105:17 | 105 | let inner = Arc::new(Inner::new()); | ^^^^^^^^^^^^^^^^^^^^^^ | = help: consider using `Rc` instead or wrapping `T` in a std::sync type like `Mutex` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#arc_with_non_send_sync error: could not compile `futures-channel` (lib) due to 3 previous errors error: usage of `Arc` where `T` is not `Send` or `Sync` --> futures-util/src/future/future/shared.rs:101:28 | 101 | Self { inner: Some(Arc::new(inner)), waker_key: NULL_WAKER_KEY } | ^^^^^^^^^^^^^^^ | = help: consider using `Rc` instead or wrapping `T` in a std::sync type like `Mutex` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#arc_with_non_send_sync = note: `#[deny(clippy::arc_with_non_send_sync)]` on by default error: usage of `Arc` where `T` is not `Send` or `Sync` --> futures-util/src/stream/futures_unordered/mod.rs:131:34 | 131 | let ready_to_run_queue = Arc::new(ReadyToRunQueue { | __________________________________^ 132 | | waker: AtomicWaker::new(), 133 | | head: AtomicPtr::new(stub_ptr as *mut _), 134 | | tail: UnsafeCell::new(stub_ptr), 135 | | stub, 136 | | }); | |__________^ | = help: consider using `Rc` instead or wrapping `T` in a std::sync type like `Mutex` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#arc_with_non_send_sync error: usage of `Arc` where `T` is not `Send` or `Sync` --> futures-util/src/lock/bilock.rs:64:19 | 64 | let arc = Arc::new(Inner { | ___________________^ 65 | | state: AtomicPtr::new(ptr::null_mut()), 66 | | value: Some(UnsafeCell::new(t)), 67 | | }); | |__________^ | = help: consider using `Rc` instead or wrapping `T` in a std::sync type like `Mutex` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#arc_with_non_send_sync ``` --- futures-channel/src/lib.rs | 1 + futures-util/src/lib.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/futures-channel/src/lib.rs b/futures-channel/src/lib.rs index 4cd936d55..4bc9370ae 100644 --- a/futures-channel/src/lib.rs +++ b/futures-channel/src/lib.rs @@ -26,6 +26,7 @@ allow(dead_code, unused_assignments, unused_variables) ) ))] +#![allow(clippy::arc_with_non_send_sync)] // false positive https://github.com/rust-lang/rust-clippy/issues/11076 #[cfg(not(futures_no_atomic_cas))] #[cfg(feature = "alloc")] diff --git a/futures-util/src/lib.rs b/futures-util/src/lib.rs index e00faf477..dd8ab2cdc 100644 --- a/futures-util/src/lib.rs +++ b/futures-util/src/lib.rs @@ -19,6 +19,7 @@ ))] #![cfg_attr(docsrs, feature(doc_cfg))] #![allow(clippy::needless_borrow)] // https://github.com/rust-lang/futures-rs/pull/2558#issuecomment-1030745203 +#![allow(clippy::arc_with_non_send_sync)] // false positive https://github.com/rust-lang/rust-clippy/issues/11076 #[cfg(all(feature = "bilock", not(feature = "unstable")))] compile_error!("The `bilock` feature requires the `unstable` feature as an explicit opt-in to unstable features"); From b556c1c61e97752e090521bdb062dfa1f7490ca4 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Tue, 11 Jul 2023 01:43:27 +0900 Subject: [PATCH 4/4] Fix clippy::useless_conversion warning ``` warning: explicit call to `.into_iter()` in function argument accepting `IntoIterator` --> futures/tests/stream_select_all.rs:83:38 | 83 | ...ec![stream::iter(vec![1].into_iter()), stream::iter(vec![2].i... | ^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `vec![1]` | note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()` --> /Users/taiki/projects/sources/rust-lang/futures-rs/futures-util/src/stream/iter.rs:31:8 | 31 | I: IntoIterator, | ^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion = note: `#[warn(clippy::useless_conversion)]` on by default warning: explicit call to `.into_iter()` in function argument accepting `IntoIterator` --> futures/tests/stream_select_all.rs:83:73 | 83 | ...)), stream::iter(vec![2].into_iter())]); | ^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `vec![2]` | note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()` --> /Users/taiki/projects/sources/rust-lang/futures-rs/futures-util/src/stream/iter.rs:31:8 | 31 | I: IntoIterator, | ^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion warning: explicit call to `.into_iter()` in function argument accepting `IntoIterator` --> futures/tests/stream_select_all.rs:91:29 | 91 | tasks.push(stream::iter(vec![3].into_iter())); | ^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `vec![3]` | note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()` --> /Users/taiki/projects/sources/rust-lang/futures-rs/futures-util/src/stream/iter.rs:31:8 | 31 | I: IntoIterator, | ^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion warning: explicit call to `.into_iter()` in function argument accepting `IntoIterator` --> futures/tests/async_await_macros.rs:325:41 | 325 | ...ct!(stream::iter(vec![1].into_iter()), stream::iter(vec![1].... | ^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `vec![1]` | note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()` --> /Users/taiki/projects/sources/rust-lang/futures-rs/futures-util/src/stream/iter.rs:31:8 | 31 | I: IntoIterator, | ^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion = note: `#[warn(clippy::useless_conversion)]` on by default warning: explicit call to `.into_iter()` in function argument accepting `IntoIterator` --> futures/tests/async_await_macros.rs:325:76 | 325 | ...)), stream::iter(vec![1].into_iter())); | ^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `vec![1]` | note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()` --> /Users/taiki/projects/sources/rust-lang/futures-rs/futures-util/src/stream/iter.rs:31:8 | 31 | I: IntoIterator, | ^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion ``` --- futures/tests/async_await_macros.rs | 3 +-- futures/tests/stream_select_all.rs | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/futures/tests/async_await_macros.rs b/futures/tests/async_await_macros.rs index 82a617f2c..e87a5bf05 100644 --- a/futures/tests/async_await_macros.rs +++ b/futures/tests/async_await_macros.rs @@ -321,8 +321,7 @@ fn stream_select() { assert_eq!(endless_ones.next().await, Some(1)); assert_eq!(endless_ones.next().await, Some(1)); - let mut finite_list = - stream_select!(stream::iter(vec![1].into_iter()), stream::iter(vec![1].into_iter())); + let mut finite_list = stream_select!(stream::iter(vec![1]), stream::iter(vec![1])); assert_eq!(finite_list.next().await, Some(1)); assert_eq!(finite_list.next().await, Some(1)); assert_eq!(finite_list.next().await, None); diff --git a/futures/tests/stream_select_all.rs b/futures/tests/stream_select_all.rs index fdeb7b997..12a993667 100644 --- a/futures/tests/stream_select_all.rs +++ b/futures/tests/stream_select_all.rs @@ -79,8 +79,7 @@ fn works_1() { #[test] fn clear() { - let mut tasks = - select_all(vec![stream::iter(vec![1].into_iter()), stream::iter(vec![2].into_iter())]); + let mut tasks = select_all(vec![stream::iter(vec![1]), stream::iter(vec![2])]); assert_eq!(block_on(tasks.next()), Some(1)); assert!(!tasks.is_empty()); @@ -88,7 +87,7 @@ fn clear() { tasks.clear(); assert!(tasks.is_empty()); - tasks.push(stream::iter(vec![3].into_iter())); + tasks.push(stream::iter(vec![3])); assert!(!tasks.is_empty()); tasks.clear();