Skip to content

Commit 5c2f3d9

Browse files
taiki-ecramertj
authored andcommitted
Adjust Debug implementations
1 parent 1488b8a commit 5c2f3d9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+464
-142
lines changed

futures-channel/src/mpsc/mod.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,11 @@ pub struct TryRecvError {
168168
}
169169

170170
impl fmt::Display for SendError {
171-
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
171+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
172172
if self.is_full() {
173-
write!(fmt, "send failed because channel is full")
173+
write!(f, "send failed because channel is full")
174174
} else {
175-
write!(fmt, "send failed because receiver is gone")
175+
write!(f, "send failed because receiver is gone")
176176
}
177177
}
178178
}
@@ -198,19 +198,19 @@ impl SendError {
198198
}
199199

200200
impl<T> fmt::Debug for TrySendError<T> {
201-
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
202-
fmt.debug_struct("TrySendError")
201+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
202+
f.debug_struct("TrySendError")
203203
.field("kind", &self.err.kind)
204204
.finish()
205205
}
206206
}
207207

208208
impl<T> fmt::Display for TrySendError<T> {
209-
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
209+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
210210
if self.is_full() {
211-
write!(fmt, "send failed because channel is full")
211+
write!(f, "send failed because channel is full")
212212
} else {
213-
write!(fmt, "send failed because receiver is gone")
213+
write!(f, "send failed because receiver is gone")
214214
}
215215
}
216216
}
@@ -240,15 +240,15 @@ impl<T> TrySendError<T> {
240240
}
241241

242242
impl fmt::Debug for TryRecvError {
243-
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
244-
fmt.debug_tuple("TryRecvError")
243+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
244+
f.debug_tuple("TryRecvError")
245245
.finish()
246246
}
247247
}
248248

249249
impl fmt::Display for TryRecvError {
250-
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
251-
write!(fmt, "receiver channel is empty")
250+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
251+
write!(f, "receiver channel is empty")
252252
}
253253
}
254254

futures-channel/src/oneshot.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,8 @@ impl<T> Drop for Sender<T> {
382382
pub struct Canceled;
383383

384384
impl fmt::Display for Canceled {
385-
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
386-
write!(fmt, "oneshot canceled")
385+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
386+
write!(f, "oneshot canceled")
387387
}
388388
}
389389

futures-core/src/task/__internal/atomic_waker.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,8 @@ impl Default for AtomicWaker {
313313
}
314314

315315
impl fmt::Debug for AtomicWaker {
316-
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
317-
write!(fmt, "AtomicWaker")
316+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
317+
write!(f, "AtomicWaker")
318318
}
319319
}
320320

futures-util/src/compat/compat01as03.rs

+1
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ where
307307

308308
struct NotifyWaker(task03::Waker);
309309

310+
#[allow(missing_debug_implementations)] // false positive: this is private type
310311
#[derive(Clone)]
311312
struct WakerToHandle<'a>(&'a task03::Waker);
312313

futures-util/src/compat/executor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ where Ex: Executor01<Executor01Future> + Clone + Send + 'static
6060

6161
/// Converts a futures 0.1 [`Executor`](futures_01::future::Executor) into a
6262
/// futures 0.3 [`Spawn`](futures_core::task::Spawn).
63-
#[derive(Clone)]
63+
#[derive(Debug, Clone)]
6464
pub struct Executor01As03<Ex> {
6565
executor01: Ex
6666
}

futures-util/src/compat/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
//! This module is only available when the `compat` feature of this
44
//! library is activated.
55
6-
#![allow(missing_debug_implementations)]
7-
86
mod executor;
97
pub use self::executor::{Executor01CompatExt, Executor01Future, Executor01As03};
108

futures-util/src/future/flatten.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ impl<Fut> fmt::Debug for Flatten<Fut>
3131
where Fut: Future + fmt::Debug,
3232
Fut::Output: Future + fmt::Debug,
3333
{
34-
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
35-
fmt.debug_struct("Flatten")
34+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
35+
f.debug_struct("Flatten")
3636
.field("state", &self.state)
3737
.finish()
3838
}

futures-util/src/future/flatten_stream.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ impl<Fut> fmt::Debug for FlattenStream<Fut>
2525
where Fut: Future + fmt::Debug,
2626
Fut::Output: fmt::Debug,
2727
{
28-
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
29-
fmt.debug_struct("FlattenStream")
28+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
29+
f.debug_struct("FlattenStream")
3030
.field("state", &self.state)
3131
.finish()
3232
}

futures-util/src/future/join.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ macro_rules! generate {
2626
$Fut::Output: fmt::Debug,
2727
)*
2828
{
29-
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
30-
fmt.debug_struct(stringify!($Join))
29+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
30+
f.debug_struct(stringify!($Join))
3131
$(.field(stringify!($Fut), &self.$Fut))*
3232
.finish()
3333
}

futures-util/src/future/join_all.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ where
7070
F: Future + fmt::Debug,
7171
F::Output: fmt::Debug,
7272
{
73-
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
74-
fmt.debug_struct("JoinAll")
73+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
74+
f.debug_struct("JoinAll")
7575
.field("elems", &self.elems)
7676
.finish()
7777
}

futures-util/src/future/poll_fn.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
//! Definition of the `PollFn` adapter combinator
22
3+
use core::fmt;
34
use core::pin::Pin;
45
use futures_core::future::Future;
56
use futures_core::task::{Context, Poll};
67

78
/// Future for the [`poll_fn`] function.
8-
#[derive(Debug)]
99
#[must_use = "futures do nothing unless you `.await` or poll them"]
1010
pub struct PollFn<F> {
1111
f: F,
@@ -40,6 +40,12 @@ where
4040
PollFn { f }
4141
}
4242

43+
impl<F> fmt::Debug for PollFn<F> {
44+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
45+
f.debug_struct("PollFn").finish()
46+
}
47+
}
48+
4349
impl<T, F> Future for PollFn<F>
4450
where F: FnMut(&mut Context<'_>) -> Poll<T>,
4551
{

futures-util/src/future/shared.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@ struct Notifier {
3131
impl<Fut: Future> Unpin for Shared<Fut> {}
3232

3333
impl<Fut: Future> fmt::Debug for Shared<Fut> {
34-
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
35-
fmt.debug_struct("Shared")
34+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
35+
f.debug_struct("Shared")
3636
.field("inner", &self.inner)
3737
.field("waker_key", &self.waker_key)
3838
.finish()
3939
}
4040
}
4141

4242
impl<Fut: Future> fmt::Debug for Inner<Fut> {
43-
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
44-
fmt.debug_struct("Inner").finish()
43+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
44+
f.debug_struct("Inner").finish()
4545
}
4646
}
4747

futures-util/src/io/buf_reader.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ impl<R: AsyncRead> AsyncBufRead for BufReader<R> {
197197
}
198198

199199
impl<R: AsyncRead + fmt::Debug> fmt::Debug for BufReader<R> {
200-
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
201-
fmt.debug_struct("BufReader")
200+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
201+
f.debug_struct("BufReader")
202202
.field("reader", &self.inner)
203203
.field("buffer", &format_args!("{}/{}", self.cap - self.pos, self.buf.len()))
204204
.finish()

futures-util/src/io/buf_writer.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ impl<W: AsyncWrite> AsyncWrite for BufWriter<W> {
157157
}
158158

159159
impl<W: AsyncWrite + fmt::Debug> fmt::Debug for BufWriter<W> {
160-
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
161-
fmt.debug_struct("BufWriter")
160+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
161+
f.debug_struct("BufWriter")
162162
.field("writer", &self.inner)
163163
.field("buffer", &format_args!("{}/{}", self.buf.len(), self.buf.capacity()))
164164
.field("written", &self.written)

futures-util/src/lock/bilock.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -199,16 +199,16 @@ impl<T> Drop for Inner<T> {
199199
pub struct ReuniteError<T>(pub BiLock<T>, pub BiLock<T>);
200200

201201
impl<T> fmt::Debug for ReuniteError<T> {
202-
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
203-
fmt.debug_tuple("ReuniteError")
202+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
203+
f.debug_tuple("ReuniteError")
204204
.field(&"...")
205205
.finish()
206206
}
207207
}
208208

209209
impl<T> fmt::Display for ReuniteError<T> {
210-
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
211-
write!(fmt, "tried to reunite two BiLocks that don't form a pair")
210+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
211+
write!(f, "tried to reunite two BiLocks that don't form a pair")
212212
}
213213
}
214214

futures-util/src/sink/with.rs

+22-12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use core::fmt;
12
use core::marker::PhantomData;
23
use core::mem;
34
use core::pin::Pin;
@@ -8,19 +9,34 @@ use futures_sink::Sink;
89
use pin_utils::{unsafe_pinned, unsafe_unpinned};
910

1011
/// Sink for the [`with`](super::SinkExt::with) method.
11-
#[derive(Debug)]
1212
#[must_use = "sinks do nothing unless polled"]
13-
pub struct With<Si, Item, U, Fut, F>
14-
where Si: Sink<Item>,
15-
F: FnMut(U) -> Fut,
16-
Fut: Future,
17-
{
13+
pub struct With<Si, Item, U, Fut, F> {
1814
sink: Si,
1915
f: F,
2016
state: State<Fut, Item>,
2117
_phantom: PhantomData<fn(U)>,
2218
}
2319

20+
impl<Si, Item, U, Fut, F> Unpin for With<Si, Item, U, Fut, F>
21+
where
22+
Si: Unpin,
23+
Fut: Unpin,
24+
{}
25+
26+
impl<Si, Item, U, Fut, F> fmt::Debug for With<Si, Item, U, Fut, F>
27+
where
28+
Si: fmt::Debug,
29+
Fut: fmt::Debug,
30+
Item: fmt::Debug,
31+
{
32+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
33+
f.debug_struct("With")
34+
.field("sink", &self.sink)
35+
.field("state", &self.state)
36+
.finish()
37+
}
38+
}
39+
2440
impl<Si, Item, U, Fut, F> With<Si, Item, U, Fut, F>
2541
where Si: Sink<Item>,
2642
F: FnMut(U) -> Fut,
@@ -44,12 +60,6 @@ where Si: Sink<Item>,
4460
}
4561
}
4662

47-
impl<Si, Item, U, Fut, F> Unpin for With<Si, Item, U, Fut, F>
48-
where Si: Sink<Item> + Unpin,
49-
F: FnMut(U) -> Fut,
50-
Fut: Future + Unpin,
51-
{}
52-
5363
#[derive(Debug)]
5464
enum State<Fut, T> {
5565
Empty,

futures-util/src/sink/with_flat_map.rs

+17-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use core::fmt;
12
use core::marker::PhantomData;
23
use core::pin::Pin;
34
use futures_core::stream::Stream;
@@ -6,13 +7,10 @@ use futures_sink::Sink;
67
use pin_utils::{unsafe_pinned, unsafe_unpinned};
78

89
/// Sink for the [`with_flat_map`](super::SinkExt::with_flat_map) method.
9-
#[derive(Debug)]
1010
#[must_use = "sinks do nothing unless polled"]
1111
pub struct WithFlatMap<Si, Item, U, St, F>
1212
where
1313
Si: Sink<Item>,
14-
F: FnMut(U) -> St,
15-
St: Stream<Item = Result<Item, Si::SinkError>>,
1614
{
1715
sink: Si,
1816
f: F,
@@ -24,10 +22,24 @@ where
2422
impl<Si, Item, U, St, F> Unpin for WithFlatMap<Si, Item, U, St, F>
2523
where
2624
Si: Sink<Item> + Unpin,
27-
F: FnMut(U) -> St,
28-
St: Stream<Item = Result<Item, Si::SinkError>> + Unpin,
25+
St: Unpin,
2926
{}
3027

28+
impl<Si, Item, U, St, F> fmt::Debug for WithFlatMap<Si, Item, U, St, F>
29+
where
30+
Si: Sink<Item> + fmt::Debug,
31+
St: fmt::Debug,
32+
Item: fmt::Debug,
33+
{
34+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
35+
f.debug_struct("WithFlatMap")
36+
.field("sink", &self.sink)
37+
.field("stream", &self.stream)
38+
.field("buffer", &self.buffer)
39+
.finish()
40+
}
41+
}
42+
3143
impl<Si, Item, U, St, F> WithFlatMap<Si, Item, U, St, F>
3244
where
3345
Si: Sink<Item>,

futures-util/src/stream/buffer_unordered.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ where
3131
St: Stream + fmt::Debug,
3232
St::Item: Future,
3333
{
34-
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
35-
fmt.debug_struct("BufferUnordered")
34+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
35+
f.debug_struct("BufferUnordered")
3636
.field("stream", &self.stream)
3737
.field("in_progress_queue", &self.in_progress_queue)
3838
.field("max", &self.max)

futures-util/src/stream/buffered.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ where
3030
St: Stream + fmt::Debug,
3131
St::Item: Future,
3232
{
33-
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
34-
fmt.debug_struct("Buffered")
33+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
34+
f.debug_struct("Buffered")
3535
.field("stream", &self.stream)
3636
.field("in_progress_queue", &self.in_progress_queue)
3737
.field("max", &self.max)

0 commit comments

Comments
 (0)