From b4fa47bd09f8eb3925d2416b429f2c238855e731 Mon Sep 17 00:00:00 2001 From: Taylor Cramer Date: Wed, 25 Oct 2017 17:57:25 -0700 Subject: [PATCH] Set Future types as must_use --- src/io/copy.rs | 1 + src/io/flush.rs | 1 + src/io/read.rs | 1 + src/io/read_exact.rs | 1 + src/io/read_to_end.rs | 1 + src/io/read_until.rs | 1 + src/io/write_all.rs | 1 + src/net/tcp.rs | 2 ++ src/net/udp/mod.rs | 2 ++ src/reactor/timeout.rs | 1 + 10 files changed, 12 insertions(+) diff --git a/src/io/copy.rs b/src/io/copy.rs index fa5677e04..d5f5c34d6 100644 --- a/src/io/copy.rs +++ b/src/io/copy.rs @@ -8,6 +8,7 @@ use futures::{Future, Poll}; /// bytes copied or an error if one happens. /// /// [`copy`]: fn.copy.html +#[must_use = "futures do nothing unless polled"] pub struct Copy { reader: R, read_done: bool, diff --git a/src/io/flush.rs b/src/io/flush.rs index f65164c08..5585e51b9 100644 --- a/src/io/flush.rs +++ b/src/io/flush.rs @@ -9,6 +9,7 @@ use futures::{Poll, Future, Async}; /// Created by the [`flush`] function. /// /// [`flush`]: fn.flush.html +#[must_use = "futures do nothing unless polled"] pub struct Flush { a: Option, } diff --git a/src/io/read.rs b/src/io/read.rs index 51bf9667f..f81007e9c 100644 --- a/src/io/read.rs +++ b/src/io/read.rs @@ -26,6 +26,7 @@ pub fn read(rd: R, buf: T) -> Read /// a buffer. /// /// Created by the [`read`] function. +#[must_use = "futures do nothing unless polled"] pub struct Read { state: State, } diff --git a/src/io/read_exact.rs b/src/io/read_exact.rs index bb0cea135..f4c51d542 100644 --- a/src/io/read_exact.rs +++ b/src/io/read_exact.rs @@ -9,6 +9,7 @@ use futures::{Poll, Future}; /// Created by the [`read_exact`] function. /// /// [`read_exact`]: fn.read_exact.html +#[must_use = "futures do nothing unless polled"] pub struct ReadExact { state: State, } diff --git a/src/io/read_to_end.rs b/src/io/read_to_end.rs index 63d5a82a5..e1b792d2b 100644 --- a/src/io/read_to_end.rs +++ b/src/io/read_to_end.rs @@ -9,6 +9,7 @@ use futures::{Poll, Future}; /// Created by the [`read_to_end`] function. /// /// [`read_to_end`]: fn.read_to_end.html +#[must_use = "futures do nothing unless polled"] pub struct ReadToEnd { state: State, } diff --git a/src/io/read_until.rs b/src/io/read_until.rs index 4e275cdc5..4263c5f12 100644 --- a/src/io/read_until.rs +++ b/src/io/read_until.rs @@ -9,6 +9,7 @@ use futures::{Poll, Future}; /// Created by the [`read_until`] function. /// /// [`read_until`]: fn.read_until.html +#[must_use = "futures do nothing unless polled"] pub struct ReadUntil { state: State, } diff --git a/src/io/write_all.rs b/src/io/write_all.rs index 949db4750..8916be662 100644 --- a/src/io/write_all.rs +++ b/src/io/write_all.rs @@ -8,6 +8,7 @@ use futures::{Poll, Future}; /// This is created by the [`write_all`] top-level method. /// /// [`write_all`]: fn.write_all.html +#[must_use = "futures do nothing unless polled"] pub struct WriteAll { state: State, } diff --git a/src/net/tcp.rs b/src/net/tcp.rs index e94f6fe5c..e1a680389 100644 --- a/src/net/tcp.rs +++ b/src/net/tcp.rs @@ -235,10 +235,12 @@ pub struct TcpStream { /// Future returned by `TcpStream::connect` which will resolve to a `TcpStream` /// when the stream is connected. +#[must_use = "futures do nothing unless polled"] pub struct TcpStreamNew { inner: TcpStreamNewState, } +#[must_use = "futures do nothing unless polled"] enum TcpStreamNewState { Waiting(TcpStream), Error(io::Error), diff --git a/src/net/udp/mod.rs b/src/net/udp/mod.rs index ad14fe981..36c006516 100644 --- a/src/net/udp/mod.rs +++ b/src/net/udp/mod.rs @@ -394,6 +394,7 @@ impl fmt::Debug for UdpSocket { /// A future used to write the entire contents of some data to a UDP socket. /// /// This is created by the `UdpSocket::send_dgram` method. +#[must_use = "futures do nothing unless polled"] pub struct SendDgram { state: SendState, } @@ -441,6 +442,7 @@ impl Future for SendDgram /// A future used to receive a datagram from a UDP socket. /// /// This is created by the `UdpSocket::recv_dgram` method. +#[must_use = "futures do nothing unless polled"] pub struct RecvDgram { state: RecvState, } diff --git a/src/reactor/timeout.rs b/src/reactor/timeout.rs index 5c96e5b0e..b4e19180e 100644 --- a/src/reactor/timeout.rs +++ b/src/reactor/timeout.rs @@ -18,6 +18,7 @@ use reactor::timeout_token::TimeoutToken; /// Note that timeouts are not intended for high resolution timers, but rather /// they will likely fire some granularity after the exact instant that they're /// otherwise indicated to fire at. +#[must_use = "futures do nothing unless polled"] #[derive(Debug)] pub struct Timeout { token: TimeoutToken,