Improve error messages with #[diagnostic::do_not_recommend] (#3588)

This commit is contained in:
Jonas Platte
2025-12-27 10:22:51 +01:00
parent aba8046921
commit f72c298ee8
12 changed files with 40 additions and 37 deletions
+4
View File
@@ -35,6 +35,9 @@ pub trait OptionalFromRequest<S, M = private::ViaRequest>: Sized {
) -> impl Future<Output = Result<Option<Self>, Self::Rejection>> + Send;
}
// Compiler hint just says that there is an impl for Option<T>, not mentioning
// the bounds, which is not very helpful.
#[diagnostic::do_not_recommend]
impl<S, T> FromRequestParts<S> for Option<T>
where
T: OptionalFromRequestParts<S>,
@@ -50,6 +53,7 @@ where
}
}
#[diagnostic::do_not_recommend]
impl<S, T> FromRequest<S> for Option<T>
where
T: OptionalFromRequest<S>,
+3
View File
@@ -65,6 +65,7 @@ where
}
}
#[diagnostic::do_not_recommend] // pretty niche impl
impl<S> FromRequest<S> for BytesMut
where
S: Send + Sync,
@@ -134,6 +135,7 @@ where
}
}
#[diagnostic::do_not_recommend] // pretty niche impl
impl<S> FromRequestParts<S> for Parts
where
S: Send + Sync,
@@ -145,6 +147,7 @@ where
}
}
#[diagnostic::do_not_recommend] // pretty niche impl
impl<S> FromRequestParts<S> for Extensions
where
S: Send + Sync,
+3
View File
@@ -3,6 +3,7 @@ use crate::response::{IntoResponse, Response};
use http::request::Parts;
use std::{convert::Infallible, future::Future};
#[diagnostic::do_not_recommend]
impl<S> FromRequestParts<S> for ()
where
S: Send + Sync,
@@ -18,6 +19,7 @@ macro_rules! impl_from_request {
(
[$($ty:ident),*], $last:ident
) => {
#[diagnostic::do_not_recommend]
#[allow(non_snake_case, unused_mut, unused_variables)]
impl<S, $($ty,)* $last> FromRequestParts<S> for ($($ty,)* $last,)
where
@@ -43,6 +45,7 @@ macro_rules! impl_from_request {
// This impl must not be generic over M, otherwise it would conflict with the blanket
// implementation of `FromRequest<S, Mut>` for `T: FromRequestParts<S>`.
#[diagnostic::do_not_recommend]
#[allow(non_snake_case, unused_mut, unused_variables)]
impl<S, $($ty,)* $last> FromRequest<S> for ($($ty,)* $last,)
where