From 71a909799b331ad3bc2ac07e7f5fd8b9fd235028 Mon Sep 17 00:00:00 2001 From: Sam Kirby Date: Tue, 2 Jan 2024 22:18:37 +0000 Subject: [PATCH] Add `must_use` attribute to `Serve` This commit adds the `must_use` attribute to `Serve` and `WithGracefulShutdown` so that a failure to await these raises a diagnostic message. --- axum/src/serve.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/axum/src/serve.rs b/axum/src/serve.rs index 9850af2787f..b253cb5defd 100644 --- a/axum/src/serve.rs +++ b/axum/src/serve.rs @@ -108,6 +108,7 @@ where /// Future returned by [`serve`]. #[cfg(all(feature = "tokio", any(feature = "http1", feature = "http2")))] +#[must_use = "futures must be awaited or polled"] pub struct Serve { tcp_listener: TcpListener, make_service: M, @@ -234,6 +235,7 @@ where /// Serve future with graceful shutdown enabled. #[cfg(all(feature = "tokio", any(feature = "http1", feature = "http2")))] +#[must_use = "futures must be awaited or polled"] pub struct WithGracefulShutdown { tcp_listener: TcpListener, make_service: M,