Skip to content
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

0.3 backport #2631

Merged
merged 33 commits into from
Aug 14, 2022
Merged

0.3 backport #2631

merged 33 commits into from
Aug 14, 2022

Conversation

taiki-e and others added 30 commits August 14, 2022 20:01
```
error: the feature `cfg_target_has_atomic` has been stable since 1.60.0 and no longer requires an attribute to enable
 --> futures/tests/no-std/src/lib.rs:3:12
  |
3 | #![feature(cfg_target_has_atomic)]
  |            ^^^^^^^^^^^^^^^^^^^^^
```
```
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
   --> futures-executor/src/thread_pool.rs:349:9
    |
349 | /         match arc_self.mutex.notify() {
350 | |             Ok(task) => arc_self.exec.state.send(Message::Run(task)),
351 | |             Err(()) => {}
352 | |         }
    | |_________^ help: try this: `if let Ok(task) = arc_self.mutex.notify() { arc_self.exec.state.send(Message::Run(task)) }`
    |
    = note: `-D clippy::single-match` implied by `-D warnings`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
```
The IntoIter impl advances the head pointer every iteration, but this breaks the linked list invariant that the head's prev should be null.

If the iteration is not done to completion, on subsequent drop, FuturesUnordered::unlink relies on this broken invariant and ends up panicking.

The fix is to maintain the `head->prev == null` invariant while iterating. Also added a test for this bug.
LocalPool::try_run_one and run_until_stalled now correctly re-try when a
future "yields" by calling wake and returning Pending.
```
error: unresolved link to `select`
   --> futures-util/src/future/try_future/mod.rs:272:17
    |
272 |     /// using [`select!`] or [`join!`].
    |                 ^^^^^^^ no item named `select` in scope
    |
    = note: `-D rustdoc::broken-intra-doc-links` implied by `-D warnings`
    = note: `macro_rules` named `select` exists in this crate, but it is not in scope at this link's location

error: unresolved link to `join`
   --> futures-util/src/future/try_future/mod.rs:272:32
    |
272 |     /// using [`select!`] or [`join!`].
    |                                ^^^^^ no item named `join` in scope
    |
    = note: `macro_rules` named `join` exists in this crate, but it is not in scope at this link's location

error: unresolved link to `select`
   --> futures-util/src/future/try_future/mod.rs:320:27
    |
320 |     /// type when using [`select!`] or [`join!`].
    |                           ^^^^^^^ no item named `select` in scope
    |
    = note: `macro_rules` named `select` exists in this crate, but it is not in scope at this link's location

error: unresolved link to `join`
   --> futures-util/src/future/try_future/mod.rs:320:42
    |
320 |     /// type when using [`select!`] or [`join!`].
    |                                          ^^^^^ no item named `join` in scope
    |
    = note: `macro_rules` named `join` exists in this crate, but it is not in scope at this link's location

error: unresolved link to `select`
    --> futures-util/src/stream/stream/mod.rs:1802:15
     |
1802 |     /// the [`select!`] macro.
     |               ^^^^^^^ no item named `select` in scope
     |
     = note: `macro_rules` named `select` exists in this crate, but it is not in scope at this link's location
```
Although a relatively small change, it makes the code a little bit
more readable than the originally nested `match` expressions.
Fixes a minor typo by changing "a tasks" to "a task" in the
documentation comment for enter.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
It can be legitimately to look for the future that _never_ resolves using the name `never`. This PR ensures `pending()` shows up when making such queries.
Clippy now respects `rust-version` field in Cargo.toml.
rust-lang/rust-clippy@b776fb8
```
warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
  --> futures-util/src/future/select_all.rs:62:28
   |
62 |                 let rest = mem::replace(&mut self.inner, Vec::new());
   |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut self.inner)`
   |
   = note: `#[warn(clippy::mem_replace_with_default)]` on by default
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_default

warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
  --> futures-util/src/future/select_ok.rs:62:40
   |
62 | ...                   let rest = mem::replace(&mut self.inner, Vec::new());
   |                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut self.inner)`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_default

warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
  --> futures-util/src/stream/stream/collect.rs:22:9
   |
22 |         mem::replace(self.project().collection, Default::default())
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(self.project().collection)`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_default

warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
  --> futures-util/src/stream/stream/unzip.rs:24:10
   |
24 |         (mem::replace(this.left, Default::default()), mem::replace(this.right, Default::default()))
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(this.left)`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_default

warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
  --> futures-util/src/stream/stream/unzip.rs:24:55
   |
24 |         (mem::replace(this.left, Default::default()), mem::replace(this.right, Default::default()))
   |                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(this.right)`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_default

warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
  --> futures-util/src/stream/stream/chunks.rs:69:40
   |
69 |                         let full_buf = mem::replace(this.items, Vec::new());
   |                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(this.items)`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_default

warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
  --> futures-util/src/stream/stream/ready_chunks.rs:77:40
   |
77 |                         let full_buf = mem::replace(this.items, Vec::new());
   |                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(this.items)`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_default

warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
  --> futures-util/src/stream/try_stream/try_collect.rs:48:31
   |
48 |                 None => break mem::replace(this.items, Default::default()),
   |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(this.items)`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_default

warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
  --> futures-util/src/stream/try_stream/try_chunks.rs:74:40
   |
74 |                         let full_buf = mem::replace(this.items, Vec::new());
   |                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(this.items)`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_default

warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
  --> futures-util/src/io/lines.rs:45:29
   |
45 |         Poll::Ready(Some(Ok(mem::replace(this.buf, String::new()))))
   |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(this.buf)`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_default

warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
  --> futures-util/src/io/read_exact.rs:33:33
   |
33 |                 let (_, rest) = mem::replace(&mut this.buf, &mut []).split_at_mut(n);
   |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut this.buf)`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_default

warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
  --> futures-util/src/io/read_line.rs:25:31
   |
25 |         Self { reader, bytes: mem::replace(buf, String::new()).into_bytes(), buf, read: 0 }
   |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(buf)`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_default

warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
  --> futures-util/src/io/read_to_string.rs:25:31
   |
25 |         Self { reader, bytes: mem::replace(buf, String::new()).into_bytes(), buf, start_len }
   |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(buf)`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_default

warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
  --> futures-util/src/io/write_all.rs:33:33
   |
33 |                 let (_, rest) = mem::replace(&mut this.buf, &[]).split_at(n);
   |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut this.buf)`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_default

warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
   --> futures/tests/sink.rs:141:9
    |
141 |         mem::replace(&mut self.data, Vec::new())
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut self.data)`
    |
    = note: `#[warn(clippy::mem_replace_with_default)]` on by default
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_default
```
KamilaBorowska and others added 3 commits August 14, 2022 20:08
Those functions are trivial and non-generic. It's necessary
to use `#[inline]` to enable cross-crate inlining for
non-generic functions when LTO is disabled.
```
error: failed to get `assert_matches` as a dependency of package `futures v0.4.0-alpha.0 (/home/runner/work/futures-rs/futures-rs/futures)`

Caused by:
  failed to load source for dependency `assert_matches`

Caused by:
  Unable to update registry `https://github.com/rust-lang/crates.io-index`

Caused by:
  failed to fetch `https://github.com/rust-lang/crates.io-index`

Caused by:
  error reading from the zlib stream; class=Zlib (5)
```
@taiki-e taiki-e added the futures-0.3 Issue related to the 0.3 versions of futures label Aug 14, 2022
@taiki-e taiki-e merged commit 367dbef into 0.3 Aug 14, 2022
@taiki-e taiki-e deleted the 0.3-backport branch August 14, 2022 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
futures-0.3 Issue related to the 0.3 versions of futures
Projects
None yet
Development

Successfully merging this pull request may close these issues.