diff --git a/examples/guessing.rs b/examples/guessing.rs index a074fa9d..b8b6eff6 100644 --- a/examples/guessing.rs +++ b/examples/guessing.rs @@ -63,7 +63,7 @@ async fn main() -> Result<(), failure::Error> { let mut incoming = listener.incoming(); while let Some(stream) = incoming.next().await { - runtime::spawn(play(stream?)); + runtime::spawn(play(stream?)).await?; } Ok(()) } diff --git a/examples/tcp-echo.rs b/examples/tcp-echo.rs index 26a34959..f1ae8d93 100644 --- a/examples/tcp-echo.rs +++ b/examples/tcp-echo.rs @@ -23,7 +23,8 @@ async fn main() -> std::io::Result<()> { let (reader, writer) = &mut stream.split(); reader.copy_into(writer).await?; Ok::<(), std::io::Error>(()) - }); + }) + .await?; } Ok(()) } diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 00000000..e1f312a6 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1 @@ +unstable_features = true diff --git a/src/net/tcp.rs b/src/net/tcp.rs index f1bc14b9..8d1cd436 100644 --- a/src/net/tcp.rs +++ b/src/net/tcp.rs @@ -217,6 +217,7 @@ impl AsyncWrite for TcpStream { /// /// [`TcpStream::connect`]: struct.TcpStream.html#method.connect /// [`TcpStream`]: struct.TcpStream.html +#[must_use = "futures do nothing unless polled"] pub struct Connect { addrs: Option>>, last_err: Option, @@ -452,6 +453,7 @@ impl TcpListener { /// /// [`TcpStream::accept`]: struct.TcpStream.html#method.accept /// [`TcpStream`]: struct.TcpStream.html +#[must_use = "futures do nothing unless polled"] #[derive(Debug)] pub struct Accept<'stream> { inner: Incoming<'stream>, @@ -479,6 +481,7 @@ impl<'stream> Future for Accept<'stream> { /// [`incoming`]: struct.TcpListener.html#method.incoming /// [`accept`]: struct.TcpStream.html#method.accept /// [`TcpListener`]: struct.TcpStream.html +#[must_use = "streams do nothing unless polled"] #[derive(Debug)] pub struct Incoming<'listener> { inner: &'listener mut TcpListener, diff --git a/src/net/udp.rs b/src/net/udp.rs index 5f87d16e..3c5f92a6 100644 --- a/src/net/udp.rs +++ b/src/net/udp.rs @@ -358,6 +358,7 @@ impl UdpSocket { /// On success, returns the number of bytes written. /// /// [`UdpSocket::send_to`]: struct.UdpSocket.html#method.send_to +#[must_use = "futures do nothing unless polled"] #[derive(Debug)] pub struct SendTo<'socket, 'buf> { /// The open socket we use to send the message from. @@ -392,6 +393,7 @@ impl<'socket, 'buf> Future for SendTo<'socket, 'buf> { /// On success, returns the number of bytes read and the origin. /// /// [`UdpSocket::recv_from`]: struct.UdpSocket.html#method.recv_from +#[must_use = "futures do nothing unless polled"] #[derive(Debug)] pub struct RecvFrom<'socket, 'buf> { socket: &'socket mut UdpSocket, diff --git a/src/task.rs b/src/task.rs index 5568cb68..83c9a38d 100644 --- a/src/task.rs +++ b/src/task.rs @@ -45,6 +45,7 @@ where /// A handle that awaits the result of a [`spawn`]ed future. /// /// [`spawn`]: fn.spawn.html +#[must_use = "futures do nothing unless polled"] #[derive(Debug)] pub struct JoinHandle { pub(crate) rx: futures::channel::oneshot::Receiver,