diff --git a/src/adaptors/auto_send.rs b/src/adaptors/auto_send.rs index 21db37b8..7732c5db 100644 --- a/src/adaptors/auto_send.rs +++ b/src/adaptors/auto_send.rs @@ -116,6 +116,7 @@ download_forward! { { this => this.inner() } } +#[must_use = "Futures are lazy and do nothing unless polled or awaited"] #[pin_project::pin_project] pub struct AutoRequest(#[pin] Inner); diff --git a/src/adaptors/cache_me.rs b/src/adaptors/cache_me.rs index 1d3b696c..e8e2e27f 100644 --- a/src/adaptors/cache_me.rs +++ b/src/adaptors/cache_me.rs @@ -123,6 +123,7 @@ download_forward! { { this => this.inner() } } +#[must_use = "Requests are lazy and do nothing unless sent"] pub struct CachedMeRequest>(Inner, GetMe); enum Inner> { diff --git a/src/adaptors/erased.rs b/src/adaptors/erased.rs index cd92c122..038b052d 100644 --- a/src/adaptors/erased.rs +++ b/src/adaptors/erased.rs @@ -35,6 +35,7 @@ impl<'a, E> ErasedRequester<'a, E> { } /// [`Request`] with erased type. +#[must_use = "Requests are lazy and do nothing unless sent"] pub struct ErasedRequest<'a, T, E> { inner: Box + 'a>, } diff --git a/src/adaptors/throttle.rs b/src/adaptors/throttle.rs index 7cae78ac..31b70074 100644 --- a/src/adaptors/throttle.rs +++ b/src/adaptors/throttle.rs @@ -663,6 +663,7 @@ impl From<&ChatId> for ChatIdHash { } } +#[must_use = "Requests are lazy and do nothing unless sent"] pub struct ThrottlingRequest { request: R, chat_id: fn(&R::Payload) -> ChatIdHash, diff --git a/src/adaptors/trace.rs b/src/adaptors/trace.rs index 80cf7ac9..1f59c826 100644 --- a/src/adaptors/trace.rs +++ b/src/adaptors/trace.rs @@ -141,6 +141,7 @@ where } } +#[must_use = "Requests are lazy and do nothing unless sent"] pub struct TraceRequest { inner: R, settings: Settings, diff --git a/src/local_macros.rs b/src/local_macros.rs index 27238be0..ec8d7f8d 100644 --- a/src/local_macros.rs +++ b/src/local_macros.rs @@ -255,6 +255,7 @@ macro_rules! impl_payload { ") field." )] #[allow(clippy::wrong_self_convention)] + #[must_use = "Payloads and requests do nothing unless sent"] fn $field(mut self, value: T) -> Self where T: Into<$FTy>, @@ -276,6 +277,7 @@ macro_rules! impl_payload { ") field." )] #[allow(clippy::wrong_self_convention)] + #[must_use = "Payloads and requests do nothing unless sent"] fn $field(mut self, value: T) -> Self where T: ::core::iter::IntoIterator::Item>, @@ -297,6 +299,7 @@ macro_rules! impl_payload { ") field." )] #[allow(clippy::wrong_self_convention)] + #[must_use = "Payloads and requests do nothing unless sent"] fn $field(mut self, value: $FTy) -> Self { self.payload_mut().$field = Some(value); self @@ -315,6 +318,7 @@ macro_rules! impl_payload { ") field." )] #[allow(clippy::wrong_self_convention)] + #[must_use = "Payloads and requests do nothing unless sent"] fn $field(mut self, value: T) -> Self where T: Into<$FTy>, @@ -336,6 +340,7 @@ macro_rules! impl_payload { ") field." )] #[allow(clippy::wrong_self_convention)] + #[must_use = "Payloads and requests do nothing unless sent"] fn $field(mut self, value: T) -> Self where T: ::core::iter::IntoIterator::Item>, @@ -357,6 +362,7 @@ macro_rules! impl_payload { ") field." )] #[allow(clippy::wrong_self_convention)] + #[must_use = "Payloads and requests do nothing unless sent"] fn $field(mut self, value: $FTy) -> Self { self.payload_mut().$field = value; self diff --git a/src/requests/json.rs b/src/requests/json.rs index bda409e5..18517bd2 100644 --- a/src/requests/json.rs +++ b/src/requests/json.rs @@ -9,7 +9,7 @@ use crate::{ /// A ready-to-send Telegram request whose payload is sent using [JSON]. /// /// [JSON]: https://core.telegram.org/bots/api#making-requests -#[must_use = "requests do nothing until sent"] +#[must_use = "Requests are lazy and do nothing unless sent"] pub struct JsonRequest

{ bot: Bot, payload: P, diff --git a/src/requests/multipart.rs b/src/requests/multipart.rs index 87d5f884..1b873e62 100644 --- a/src/requests/multipart.rs +++ b/src/requests/multipart.rs @@ -10,7 +10,7 @@ use crate::{ /// [multipart/form-data]. /// /// [multipart/form-data]: https://core.telegram.org/bots/api#making-requests -#[must_use = "requests do nothing until sent"] +#[must_use = "Requests are lazy and do nothing unless sent"] pub struct MultipartRequest

{ bot: Bot, payload: P, diff --git a/src/requests/request.rs b/src/requests/request.rs index 3913dcb3..0dd99e86 100644 --- a/src/requests/request.rs +++ b/src/requests/request.rs @@ -59,6 +59,7 @@ pub trait Request: HasPayload { /// let _: Me = request.send().await.unwrap(); /// # }; /// ``` + #[must_use = "Futures are lazy and do nothing unless polled or awaited"] fn send(self) -> Self::Send; /// Send this request by reference. @@ -86,13 +87,10 @@ pub trait Request: HasPayload { /// } /// # }; /// ``` + #[must_use = "Futures are lazy and do nothing unless polled or awaited"] fn send_ref(&self) -> Self::SendRef; #[cfg(feature = "erased")] - #[cfg_attr( - all(any(docsrs, dep_docsrs), feature = "nightly"), - doc(cfg(feature = "erased")) - )] fn erase<'a>(self) -> crate::adaptors::erased::ErasedRequest<'a, Self::Payload, Self::Err> where Self: Sized + 'a,