From 2e4aefa7fc19e4d66152332d28baafe1349c1636 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Thu, 26 Jan 2023 16:10:45 -0800 Subject: Annotate `Command` and `Subscription` with `#[must_use]` Calling a function returning one of these types without using it is almost certainly a mistake. Luckily Rust's `#[must_use]` can help warn about this. --- futures/src/command.rs | 1 + futures/src/subscription.rs | 1 + 2 files changed, 2 insertions(+) (limited to 'futures') diff --git a/futures/src/command.rs b/futures/src/command.rs index 05c3a1d0..3d1ec3f9 100644 --- a/futures/src/command.rs +++ b/futures/src/command.rs @@ -1,4 +1,5 @@ /// A set of asynchronous actions to be performed by some runtime. +#[must_use = "`Command` must be returned to runtime to take effect"] #[derive(Debug)] pub struct Command(Internal); diff --git a/futures/src/subscription.rs b/futures/src/subscription.rs index e96fa704..d18ec4f7 100644 --- a/futures/src/subscription.rs +++ b/futures/src/subscription.rs @@ -20,6 +20,7 @@ use crate::BoxStream; /// `Hasher`. /// /// [`Command`]: crate::Command +#[must_use = "`Subscription` must be returned to runtime to take effect"] pub struct Subscription { recipes: Vec>>, } -- cgit From 0ff1061d52d4ecb35018c8aab173225fe14d1e25 Mon Sep 17 00:00:00 2001 From: 13r0ck Date: Fri, 27 Jan 2023 13:16:26 -0700 Subject: Fix: Clippy lint 'let_underscore_future' --- futures/src/backend/native/async_std.rs | 1 + futures/src/backend/native/tokio.rs | 1 + 2 files changed, 2 insertions(+) (limited to 'futures') diff --git a/futures/src/backend/native/async_std.rs b/futures/src/backend/native/async_std.rs index e8641626..b324dbf1 100644 --- a/futures/src/backend/native/async_std.rs +++ b/futures/src/backend/native/async_std.rs @@ -10,6 +10,7 @@ impl crate::Executor for Executor { Ok(Self) } + #[allow(clippy::let_underscore_future)] fn spawn(&self, future: impl Future + Send + 'static) { let _ = async_std::task::spawn(future); } diff --git a/futures/src/backend/native/tokio.rs b/futures/src/backend/native/tokio.rs index f86b0ea3..dd818bd1 100644 --- a/futures/src/backend/native/tokio.rs +++ b/futures/src/backend/native/tokio.rs @@ -9,6 +9,7 @@ impl crate::Executor for Executor { tokio::runtime::Runtime::new() } + #[allow(clippy::let_underscore_future)] fn spawn(&self, future: impl Future + Send + 'static) { let _ = tokio::runtime::Runtime::spawn(self, future); } -- cgit