```
error: the item `Box` is imported redundantly
--> futures-core/src/future.rs:89:9
|
89 | use alloc::boxed::Box;
| ^^^^^^^^^^^^^^^^^
--> /rustc/381d69953bb7c3390cec0fee200f24529cb6320f/library/std/src/prelude/mod.rs:115:13
|
= note: the item `Box` is already defined here
|
= note: `-D unused-imports` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(unused_imports)]`
error: the item `Box` is imported redundantly
--> futures-core/src/stream.rs:203:9
|
203 | use alloc::boxed::Box;
| ^^^^^^^^^^^^^^^^^
--> /rustc/381d69953bb7c3390cec0fee200f24529cb6320f/library/std/src/prelude/mod.rs:115:13
|
= note: the item `Box` is already defined here
```
- add `len`, `is_empty` methods to inspect how many messages are
enqueued in the message queue.
- add test for `len` and `is_empty`
Co-authored-by: Jakub Horak <jakub.horak@ibawizard.net>
```
warning: this argument is a mutable reference, but not used mutably
--> futures-channel/src/oneshot.rs:154:33
|
154 | fn poll_canceled(&self, cx: &mut Context<'_>) -> Poll<()> {
| ^^^^^^^^^^^^^^^^ help: consider changing to: `&Context<'_>`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut
= note: `#[warn(clippy::needless_pass_by_ref_mut)]` on by default
warning: this argument is a mutable reference, but not used mutably
--> futures-channel/src/oneshot.rs:256:24
|
256 | ... recv(&self, cx: &mut Context<'_>) -> Poll<Result<T, Cancel...
| ^^^^^^^^^^^^^^^^ help: consider changing to: `&Context<'_>`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut
warning: this argument is a mutable reference, but not used mutably
--> futures-util/src/future/future/shared.rs:212:55
|
212 | ... &mut usize, cx: &mut Context<'_>) {
| ^^^^^^^^^^^^^^^^ help: consider changing to: `&Context<'_>`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut
= note: `#[warn(clippy::needless_pass_by_ref_mut)]` on by default
warning: this argument is a mutable reference, but not used mutably
--> futures-util/src/stream/stream/flatten_unordered.rs:212:39
|
212 | ..._waker(self_arc: &mut Arc<Self>, cx: &Context<'_>) {
| ^^^^^^^^^^^^^^ help: consider changing to: `&Arc<Self>`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut
warning: this argument is a mutable reference, but not used mutably
--> futures-util/src/compat/compat01as03.rs:36:36
|
36 | ...>(&mut self, cx: &mut Context<'_>, f: impl FnOnce(&mut T) ->...
| ^^^^^^^^^^^^^^^^ help: consider changing to: `&Context<'_>`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut
warning: this argument is a mutable reference, but not used mutably
--> futures-util/src/compat/compat01as03.rs:199:36
|
199 | ...>(&mut self, cx: &mut Context<'_>, f: impl FnOnce(&mut S) -...
| ^^^^^^^^^^^^^^^^ help: consider changing to: `&Context<'_>`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut
warning: this argument is a mutable reference, but not used mutably
--> futures-util/src/lock/bilock.rs:90:33
|
90 | ..._lock(&self, cx: &mut Context<'_>) -> Poll<BiLockGuard<'_, T...
| ^^^^^^^^^^^^^^^^ help: consider changing to: `&Context<'_>`
|
= warning: changing this function will impact semver compatibility
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut
warning: this argument is a mutable reference, but not used mutably
--> futures/tests/sink.rs:160:25
|
160 | fn check(&self, cx: &mut Context<'_>) -> bool {
| ^^^^^^^^^^^^^^^^ help: consider changing to: `&Context<'_>`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut
= note: `#[warn(clippy::needless_pass_by_ref_mut)]` on by default
```
```
error: usage of `Arc<T>` 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<T>` instead or wrapping `T` in a std::sync type like `Mutex<T>`
= 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<T>` 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<T>` instead or wrapping `T` in a std::sync type like `Mutex<T>`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#arc_with_non_send_sync
error: usage of `Arc<T>` 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<T>` instead or wrapping `T` in a std::sync type like `Mutex<T>`
= 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<T>` 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<T>` instead or wrapping `T` in a std::sync type like `Mutex<T>`
= 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<T>` 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<T>` instead or wrapping `T` in a std::sync type like `Mutex<T>`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#arc_with_non_send_sync
error: usage of `Arc<T>` 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<T>` instead or wrapping `T` in a std::sync type like `Mutex<T>`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#arc_with_non_send_sync
```
Prior to this diff, the Debug impl for oneshot channels printed something like:
```
Sender { inner: Inner { complete: false, data: Lock { locked: false, data: UnsafeCell }, rx_task: Lock { locked: false, data: UnsafeCell }, tx_task: Lock { locked: false, data: UnsafeCell } } }
```
which isn't very helpful. Instead, just print
`Sender { complete: false }` (or `true`, if the other end has dropped).
Note that the `T: Debug` bound is retained to allow for the possibility
of allowing slightly more interesting debug output in the future.
Allow calling `UnboundedReceiver::try_next` and `Receiver::try_next`
after `None`: do not panic.
Not-panicking is equally safe, and does not have negative performance
implication.
It is irrelevant for `Stream` implementation to panic or not (because
`Stream` behavior is unspecified after `None`), but panicking in
`try_next` just complicates the interface: returned `Ok(None)` is
reasonable assumption to have.
Consider this use case: drain the queue on drop by performing
app-specific cleanup of queued messages.
The obvious implementation would be:
```
impl Drop for MyReceiverWrapper {
fn drop(&mut self) {
while let Ok(Some(m)) self.try_next() {
cleanup(m);
}
}
}
```
Without this change, I cannot even say for sure how this code need
to be implemented to avoid panicking. E. g. is `is_closed` enough
or some additional checks need to be performed?