mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-27 00:00:24 +02:00
Improve error messages with #[diagnostic::do_not_recommend] (#3588)
This commit is contained in:
@@ -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>,
|
||||
|
||||
@@ -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,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
|
||||
|
||||
Reference in New Issue
Block a user