diff --git a/core/src/connection_reuse.rs b/core/src/connection_reuse.rs index e5db222a..f2e35842 100644 --- a/core/src/connection_reuse.rs +++ b/core/src/connection_reuse.rs @@ -562,6 +562,7 @@ where } /// Implementation of `Future` that yields the next incoming substream from a dialed connection. +#[must_use = "futures do nothing unless polled"] pub struct ConnectionReuseIncoming where T: Transport, diff --git a/core/src/either.rs b/core/src/either.rs index 9c85d427..4d5ab8c9 100644 --- a/core/src/either.rs +++ b/core/src/either.rs @@ -213,6 +213,7 @@ where } #[derive(Debug, Copy, Clone)] +#[must_use = "futures do nothing unless polled"] pub enum EitherOutbound { A(A::OutboundSubstream), B(B::OutboundSubstream), @@ -220,6 +221,7 @@ pub enum EitherOutbound { /// Implements `Stream` and dispatches all method calls to either `First` or `Second`. #[derive(Debug, Copy, Clone)] +#[must_use = "futures do nothing unless polled"] pub enum EitherListenStream { First(A), Second(B), @@ -248,6 +250,7 @@ where // If Rust had impl Trait we could use the Either enum from the futures crate and add some // modifiers to it. This custom enum is a combination of Either and these modifiers. #[derive(Debug, Copy, Clone)] +#[must_use = "futures do nothing unless polled"] pub enum EitherListenUpgrade { First(A), Second(B), diff --git a/core/src/swarm.rs b/core/src/swarm.rs index bd6b703a..719dda3e 100644 --- a/core/src/swarm.rs +++ b/core/src/swarm.rs @@ -222,6 +222,7 @@ where } /// Future that must be driven to completion in order for the swarm to work. +#[must_use = "futures do nothing unless polled"] pub struct SwarmFuture where T: MuxedTransport + 'static, // TODO: 'static :-/ diff --git a/core/src/transport/interruptible.rs b/core/src/transport/interruptible.rs index f18282b4..3638b8fe 100644 --- a/core/src/transport/interruptible.rs +++ b/core/src/transport/interruptible.rs @@ -96,6 +96,7 @@ pub struct Interrupt { _tx: oneshot::Sender<()>, } +#[must_use = "futures do nothing unless polled"] pub struct InterruptibleDial { inner: F, rx: future::Shared>, diff --git a/core/src/unique.rs b/core/src/unique.rs index bbaf134c..003ea1a5 100644 --- a/core/src/unique.rs +++ b/core/src/unique.rs @@ -342,6 +342,7 @@ impl Drop for UniqueConnec { } /// Future returned by `UniqueConnec::dial()`. +#[must_use = "futures do nothing unless polled"] pub struct UniqueConnecFuture { inner: Weak>>, } diff --git a/core/src/upgrade/choice.rs b/core/src/upgrade/choice.rs index 41238a84..f7484af1 100644 --- a/core/src/upgrade/choice.rs +++ b/core/src/upgrade/choice.rs @@ -92,6 +92,7 @@ pub enum EitherUpgradeIdentifier { // If Rust had impl Trait we could use the Either enum from the futures crate and add some // modifiers to it. This custom enum is a combination of Either and these modifiers. #[derive(Debug, Copy, Clone)] +#[must_use = "futures do nothing unless polled"] pub enum EitherConnUpgrFuture { First(A), Second(B), diff --git a/protocols/floodsub/src/lib.rs b/protocols/floodsub/src/lib.rs index 9b788f41..f90fb127 100644 --- a/protocols/floodsub/src/lib.rs +++ b/protocols/floodsub/src/lib.rs @@ -519,6 +519,7 @@ pub struct Message { } /// Implementation of `Future` that must be driven to completion in order for floodsub to work. +#[must_use = "futures do nothing unless polled"] pub struct FloodSubFuture { inner: Box>, } diff --git a/transports/ratelimit/src/lib.rs b/transports/ratelimit/src/lib.rs index 08b6aaa7..c5fa55a7 100644 --- a/transports/ratelimit/src/lib.rs +++ b/transports/ratelimit/src/lib.rs @@ -135,6 +135,7 @@ impl Stream for Listener { } } +#[must_use = "futures do nothing unless polled"] pub struct ListenerUpgrade(RateLimited); impl Future for ListenerUpgrade diff --git a/transports/relay/src/copy.rs b/transports/relay/src/copy.rs index cfa19427..0038043d 100644 --- a/transports/relay/src/copy.rs +++ b/transports/relay/src/copy.rs @@ -37,6 +37,7 @@ use tokio_io::{AsyncRead, AsyncWrite}; /// /// [`copy`]: fn.copy.html #[derive(Debug)] +#[must_use = "futures do nothing unless polled"] pub struct Copy { reader: Option, read_done: bool, diff --git a/transports/tcp/src/lib.rs b/transports/tcp/src/lib.rs index a797b019..b71dbd75 100644 --- a/transports/tcp/src/lib.rs +++ b/transports/tcp/src/lib.rs @@ -192,6 +192,7 @@ fn multiaddr_to_socketaddr(addr: &Multiaddr) -> Result { /// Future that dials a TCP/IP address. #[derive(Debug)] +#[must_use = "futures do nothing unless polled"] pub struct TcpDialFut { inner: ConnectFuture, /// Address we're dialing. Extracted when the `Future` finishes. diff --git a/transports/timeout/src/lib.rs b/transports/timeout/src/lib.rs index b9d67163..1d2f7a81 100644 --- a/transports/timeout/src/lib.rs +++ b/transports/timeout/src/lib.rs @@ -180,6 +180,7 @@ where // TODO: can be removed and replaced with an `impl Future` once impl Trait is fully stable // in Rust (https://github.com/rust-lang/rust/issues/34511) +#[must_use = "futures do nothing unless polled"] pub struct TimeoutIncoming { inner: InnerFut, timeout: Duration, @@ -204,6 +205,7 @@ where /// Wraps around a `Future`. Turns the error type from `TimeoutError` to `IoError`. // TODO: can be replaced with `impl Future` once `impl Trait` are fully stable in Rust // (https://github.com/rust-lang/rust/issues/34511) +#[must_use = "futures do nothing unless polled"] pub struct TokioTimerMapErr { inner: InnerFut, }