summaryrefslogtreecommitdiffstats
path: root/vendor/futures-channel/src
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:29 +0000
commit631cd5845e8de329d0e227aaa707d7ea228b8f8f (patch)
treea1b87c8f8cad01cf18f7c5f57a08f102771ed303 /vendor/futures-channel/src
parentAdding debian version 1.69.0+dfsg1-1. (diff)
downloadrustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.tar.xz
rustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.zip
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/futures-channel/src')
-rw-r--r--vendor/futures-channel/src/mpsc/mod.rs71
-rw-r--r--vendor/futures-channel/src/mpsc/queue.rs2
-rw-r--r--vendor/futures-channel/src/oneshot.rs4
3 files changed, 63 insertions, 14 deletions
diff --git a/vendor/futures-channel/src/mpsc/mod.rs b/vendor/futures-channel/src/mpsc/mod.rs
index 44834b7c9..cf45fe77f 100644
--- a/vendor/futures-channel/src/mpsc/mod.rs
+++ b/vendor/futures-channel/src/mpsc/mod.rs
@@ -94,13 +94,11 @@ mod queue;
#[cfg(feature = "sink")]
mod sink_impl;
-#[derive(Debug)]
struct UnboundedSenderInner<T> {
// Channel state shared between the sender and receiver.
inner: Arc<UnboundedInner<T>>,
}
-#[derive(Debug)]
struct BoundedSenderInner<T> {
// Channel state shared between the sender and receiver.
inner: Arc<BoundedInner<T>>,
@@ -122,13 +120,11 @@ impl<T> Unpin for BoundedSenderInner<T> {}
/// The transmission end of a bounded mpsc channel.
///
/// This value is created by the [`channel`](channel) function.
-#[derive(Debug)]
pub struct Sender<T>(Option<BoundedSenderInner<T>>);
/// The transmission end of an unbounded mpsc channel.
///
/// This value is created by the [`unbounded`](unbounded) function.
-#[derive(Debug)]
pub struct UnboundedSender<T>(Option<UnboundedSenderInner<T>>);
trait AssertKinds: Send + Sync + Clone {}
@@ -137,7 +133,6 @@ impl AssertKinds for UnboundedSender<u32> {}
/// The receiving end of a bounded mpsc channel.
///
/// This value is created by the [`channel`](channel) function.
-#[derive(Debug)]
pub struct Receiver<T> {
inner: Option<Arc<BoundedInner<T>>>,
}
@@ -145,7 +140,6 @@ pub struct Receiver<T> {
/// The receiving end of an unbounded mpsc channel.
///
/// This value is created by the [`unbounded`](unbounded) function.
-#[derive(Debug)]
pub struct UnboundedReceiver<T> {
inner: Option<Arc<UnboundedInner<T>>>,
}
@@ -261,7 +255,6 @@ impl fmt::Display for TryRecvError {
impl std::error::Error for TryRecvError {}
-#[derive(Debug)]
struct UnboundedInner<T> {
// Internal channel state. Consists of the number of messages stored in the
// channel as well as a flag signalling that the channel is closed.
@@ -277,7 +270,6 @@ struct UnboundedInner<T> {
recv_task: AtomicWaker,
}
-#[derive(Debug)]
struct BoundedInner<T> {
// Max buffer size of the channel. If `None` then the channel is unbounded.
buffer: usize,
@@ -300,7 +292,7 @@ struct BoundedInner<T> {
}
// Struct representation of `Inner::state`.
-#[derive(Debug, Clone, Copy)]
+#[derive(Clone, Copy)]
struct State {
// `true` when the channel is open
is_open: bool,
@@ -324,7 +316,6 @@ const MAX_CAPACITY: usize = !(OPEN_MASK);
const MAX_BUFFER: usize = MAX_CAPACITY >> 1;
// Sent to the consumer to wake up blocked producers
-#[derive(Debug)]
struct SenderTask {
task: Option<Waker>,
is_parked: bool,
@@ -947,6 +938,18 @@ impl<T> Drop for BoundedSenderInner<T> {
}
}
+impl<T> fmt::Debug for Sender<T> {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ f.debug_struct("Sender").field("closed", &self.is_closed()).finish()
+ }
+}
+
+impl<T> fmt::Debug for UnboundedSender<T> {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ f.debug_struct("UnboundedSender").field("closed", &self.is_closed()).finish()
+ }
+}
+
/*
*
* ===== impl Receiver =====
@@ -1075,6 +1078,14 @@ impl<T> Stream for Receiver<T> {
}
}
}
+
+ fn size_hint(&self) -> (usize, Option<usize>) {
+ if let Some(inner) = &self.inner {
+ decode_state(inner.state.load(SeqCst)).size_hint()
+ } else {
+ (0, Some(0))
+ }
+ }
}
impl<T> Drop for Receiver<T> {
@@ -1107,6 +1118,18 @@ impl<T> Drop for Receiver<T> {
}
}
+impl<T> fmt::Debug for Receiver<T> {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ let closed = if let Some(ref inner) = self.inner {
+ decode_state(inner.state.load(SeqCst)).is_closed()
+ } else {
+ false
+ };
+
+ f.debug_struct("Receiver").field("closed", &closed).finish()
+ }
+}
+
impl<T> UnboundedReceiver<T> {
/// Closes the receiving half of a channel, without dropping it.
///
@@ -1207,6 +1230,14 @@ impl<T> Stream for UnboundedReceiver<T> {
}
}
}
+
+ fn size_hint(&self) -> (usize, Option<usize>) {
+ if let Some(inner) = &self.inner {
+ decode_state(inner.state.load(SeqCst)).size_hint()
+ } else {
+ (0, Some(0))
+ }
+ }
}
impl<T> Drop for UnboundedReceiver<T> {
@@ -1239,6 +1270,18 @@ impl<T> Drop for UnboundedReceiver<T> {
}
}
+impl<T> fmt::Debug for UnboundedReceiver<T> {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ let closed = if let Some(ref inner) = self.inner {
+ decode_state(inner.state.load(SeqCst)).is_closed()
+ } else {
+ false
+ };
+
+ f.debug_struct("Receiver").field("closed", &closed).finish()
+ }
+}
+
/*
*
* ===== impl Inner =====
@@ -1285,6 +1328,14 @@ impl State {
fn is_closed(&self) -> bool {
!self.is_open && self.num_messages == 0
}
+
+ fn size_hint(&self) -> (usize, Option<usize>) {
+ if self.is_open {
+ (self.num_messages, None)
+ } else {
+ (self.num_messages, Some(self.num_messages))
+ }
+ }
}
/*
diff --git a/vendor/futures-channel/src/mpsc/queue.rs b/vendor/futures-channel/src/mpsc/queue.rs
index 57dc7f565..02ec633fe 100644
--- a/vendor/futures-channel/src/mpsc/queue.rs
+++ b/vendor/futures-channel/src/mpsc/queue.rs
@@ -61,7 +61,6 @@ pub(super) enum PopResult<T> {
Inconsistent,
}
-#[derive(Debug)]
struct Node<T> {
next: AtomicPtr<Self>,
value: Option<T>,
@@ -70,7 +69,6 @@ struct Node<T> {
/// The multi-producer single-consumer structure. This is not cloneable, but it
/// may be safely shared so long as it is guaranteed that there is only one
/// popper at a time (many pushers are allowed).
-#[derive(Debug)]
pub(super) struct Queue<T> {
head: AtomicPtr<Node<T>>,
tail: UnsafeCell<*mut Node<T>>,
diff --git a/vendor/futures-channel/src/oneshot.rs b/vendor/futures-channel/src/oneshot.rs
index 5af651b91..70449f43d 100644
--- a/vendor/futures-channel/src/oneshot.rs
+++ b/vendor/futures-channel/src/oneshot.rs
@@ -390,7 +390,7 @@ impl<T> Drop for Sender<T> {
}
}
-impl<T: fmt::Debug> fmt::Debug for Sender<T> {
+impl<T> fmt::Debug for Sender<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Sender").field("complete", &self.inner.complete).finish()
}
@@ -481,7 +481,7 @@ impl<T> Drop for Receiver<T> {
}
}
-impl<T: fmt::Debug> fmt::Debug for Receiver<T> {
+impl<T> fmt::Debug for Receiver<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Receiver").field("complete", &self.inner.complete).finish()
}