From fbdf539ac22563c6b8e3fb3f1844055baba12470 Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Mon, 5 Feb 2024 08:46:04 +0100 Subject: [PATCH] sync: make downgrade must_use (#6326) --- tokio/src/sync/mpsc/bounded.rs | 1 + tokio/src/sync/mpsc/unbounded.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/tokio/src/sync/mpsc/bounded.rs b/tokio/src/sync/mpsc/bounded.rs index a1e0a82d9e2..3cdba3dc237 100644 --- a/tokio/src/sync/mpsc/bounded.rs +++ b/tokio/src/sync/mpsc/bounded.rs @@ -1367,6 +1367,7 @@ impl Sender { /// towards RAII semantics, i.e. if all `Sender` instances of the /// channel were dropped and only `WeakSender` instances remain, /// the channel is closed. + #[must_use = "Downgrade creates a WeakSender without destroying the original non-weak sender."] pub fn downgrade(&self) -> WeakSender { WeakSender { chan: self.chan.downgrade(), diff --git a/tokio/src/sync/mpsc/unbounded.rs b/tokio/src/sync/mpsc/unbounded.rs index 7dff942ee70..b87b07ba653 100644 --- a/tokio/src/sync/mpsc/unbounded.rs +++ b/tokio/src/sync/mpsc/unbounded.rs @@ -572,6 +572,7 @@ impl UnboundedSender { /// towards RAII semantics, i.e. if all `UnboundedSender` instances of the /// channel were dropped and only `WeakUnboundedSender` instances remain, /// the channel is closed. + #[must_use = "Downgrade creates a WeakSender without destroying the original non-weak sender."] pub fn downgrade(&self) -> WeakUnboundedSender { WeakUnboundedSender { chan: self.chan.downgrade(),