mirror of
https://github.com/tokio-rs/axum.git
synced 2026-09-06 00:00:17 +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;
|
) -> 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>
|
impl<S, T> FromRequestParts<S> for Option<T>
|
||||||
where
|
where
|
||||||
T: OptionalFromRequestParts<S>,
|
T: OptionalFromRequestParts<S>,
|
||||||
@@ -50,6 +53,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[diagnostic::do_not_recommend]
|
||||||
impl<S, T> FromRequest<S> for Option<T>
|
impl<S, T> FromRequest<S> for Option<T>
|
||||||
where
|
where
|
||||||
T: OptionalFromRequest<S>,
|
T: OptionalFromRequest<S>,
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[diagnostic::do_not_recommend] // pretty niche impl
|
||||||
impl<S> FromRequest<S> for BytesMut
|
impl<S> FromRequest<S> for BytesMut
|
||||||
where
|
where
|
||||||
S: Send + Sync,
|
S: Send + Sync,
|
||||||
@@ -134,6 +135,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[diagnostic::do_not_recommend] // pretty niche impl
|
||||||
impl<S> FromRequestParts<S> for Parts
|
impl<S> FromRequestParts<S> for Parts
|
||||||
where
|
where
|
||||||
S: Send + Sync,
|
S: Send + Sync,
|
||||||
@@ -145,6 +147,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[diagnostic::do_not_recommend] // pretty niche impl
|
||||||
impl<S> FromRequestParts<S> for Extensions
|
impl<S> FromRequestParts<S> for Extensions
|
||||||
where
|
where
|
||||||
S: Send + Sync,
|
S: Send + Sync,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ use crate::response::{IntoResponse, Response};
|
|||||||
use http::request::Parts;
|
use http::request::Parts;
|
||||||
use std::{convert::Infallible, future::Future};
|
use std::{convert::Infallible, future::Future};
|
||||||
|
|
||||||
|
#[diagnostic::do_not_recommend]
|
||||||
impl<S> FromRequestParts<S> for ()
|
impl<S> FromRequestParts<S> for ()
|
||||||
where
|
where
|
||||||
S: Send + Sync,
|
S: Send + Sync,
|
||||||
@@ -18,6 +19,7 @@ macro_rules! impl_from_request {
|
|||||||
(
|
(
|
||||||
[$($ty:ident),*], $last:ident
|
[$($ty:ident),*], $last:ident
|
||||||
) => {
|
) => {
|
||||||
|
#[diagnostic::do_not_recommend]
|
||||||
#[allow(non_snake_case, unused_mut, unused_variables)]
|
#[allow(non_snake_case, unused_mut, unused_variables)]
|
||||||
impl<S, $($ty,)* $last> FromRequestParts<S> for ($($ty,)* $last,)
|
impl<S, $($ty,)* $last> FromRequestParts<S> for ($($ty,)* $last,)
|
||||||
where
|
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
|
// This impl must not be generic over M, otherwise it would conflict with the blanket
|
||||||
// implementation of `FromRequest<S, Mut>` for `T: FromRequestParts<S>`.
|
// implementation of `FromRequest<S, Mut>` for `T: FromRequestParts<S>`.
|
||||||
|
#[diagnostic::do_not_recommend]
|
||||||
#[allow(non_snake_case, unused_mut, unused_variables)]
|
#[allow(non_snake_case, unused_mut, unused_variables)]
|
||||||
impl<S, $($ty,)* $last> FromRequest<S> for ($($ty,)* $last,)
|
impl<S, $($ty,)* $last> FromRequest<S> for ($($ty,)* $last,)
|
||||||
where
|
where
|
||||||
|
|||||||
@@ -7,14 +7,14 @@ error[E0277]: the trait bound `bool: FromRequest<(), axum_core::extract::private
|
|||||||
= note: Function argument is not a valid axum extractor.
|
= note: Function argument is not a valid axum extractor.
|
||||||
See `https://docs.rs/axum/0.8/axum/extract/index.html` for details
|
See `https://docs.rs/axum/0.8/axum/extract/index.html` for details
|
||||||
= help: the following other types implement trait `FromRequestParts<S>`:
|
= help: the following other types implement trait `FromRequestParts<S>`:
|
||||||
`()` implements `FromRequestParts<S>`
|
`ConnectInfo<T>` implements `FromRequestParts<S>`
|
||||||
`(T1, T2)` implements `FromRequestParts<S>`
|
`Extension<T>` implements `FromRequestParts<S>`
|
||||||
`(T1, T2, T3)` implements `FromRequestParts<S>`
|
`HeaderMap` implements `FromRequestParts<S>`
|
||||||
`(T1, T2, T3, T4)` implements `FromRequestParts<S>`
|
`MatchedPath` implements `FromRequestParts<S>`
|
||||||
`(T1, T2, T3, T4, T5)` implements `FromRequestParts<S>`
|
`Method` implements `FromRequestParts<S>`
|
||||||
`(T1, T2, T3, T4, T5, T6)` implements `FromRequestParts<S>`
|
`OriginalUri` implements `FromRequestParts<S>`
|
||||||
`(T1, T2, T3, T4, T5, T6, T7)` implements `FromRequestParts<S>`
|
`Query<T>` implements `FromRequestParts<S>`
|
||||||
`(T1, T2, T3, T4, T5, T6, T7, T8)` implements `FromRequestParts<S>`
|
`RawPathParams` implements `FromRequestParts<S>`
|
||||||
and $N others
|
and $N others
|
||||||
= note: required for `bool` to implement `FromRequest<(), axum_core::extract::private::ViaParts>`
|
= note: required for `bool` to implement `FromRequest<(), axum_core::extract::private::ViaParts>`
|
||||||
note: required by a bound in `__axum_macros_check_handler_0_from_request_check`
|
note: required by a bound in `__axum_macros_check_handler_0_from_request_check`
|
||||||
|
|||||||
@@ -5,15 +5,14 @@ error[E0277]: the trait bound `NonCloneType: Clone` is not satisfied
|
|||||||
| ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `NonCloneType`, which is required by `Extension<NonCloneType>: FromRequest<(), _>`
|
| ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `NonCloneType`, which is required by `Extension<NonCloneType>: FromRequest<(), _>`
|
||||||
|
|
|
|
||||||
= help: the following other types implement trait `FromRequest<S, M>`:
|
= help: the following other types implement trait `FromRequest<S, M>`:
|
||||||
(T1, T2)
|
Body
|
||||||
(T1, T2, T3)
|
Form<T>
|
||||||
(T1, T2, T3, T4)
|
Json<T>
|
||||||
(T1, T2, T3, T4, T5)
|
RawForm
|
||||||
(T1, T2, T3, T4, T5, T6)
|
Result<T, <T as FromRequest<S>>::Rejection>
|
||||||
(T1, T2, T3, T4, T5, T6, T7)
|
String
|
||||||
(T1, T2, T3, T4, T5, T6, T7, T8)
|
axum::body::Bytes
|
||||||
(T1, T2, T3, T4, T5, T6, T7, T8, T9)
|
axum::http::Request<Body>
|
||||||
and $N others
|
|
||||||
= note: required for `Extension<NonCloneType>` to implement `FromRequestParts<()>`
|
= note: required for `Extension<NonCloneType>` to implement `FromRequestParts<()>`
|
||||||
= note: required for `Extension<NonCloneType>` to implement `FromRequest<(), axum_core::extract::private::ViaParts>`
|
= note: required for `Extension<NonCloneType>` to implement `FromRequest<(), axum_core::extract::private::ViaParts>`
|
||||||
note: required by a bound in `__axum_macros_check_test_extension_non_clone_0_from_request_check`
|
note: required by a bound in `__axum_macros_check_test_extension_non_clone_0_from_request_check`
|
||||||
|
|||||||
@@ -13,9 +13,6 @@ error[E0277]: the trait bound `fn(Extractor<()>) -> impl Future<Output = ()> {fo
|
|||||||
| required by a bound introduced by this call
|
| required by a bound introduced by this call
|
||||||
|
|
|
|
||||||
= note: Consider using `#[axum::debug_handler]` to improve the error message
|
= note: Consider using `#[axum::debug_handler]` to improve the error message
|
||||||
= help: the following other types implement trait `Handler<T, S>`:
|
|
||||||
`Layered<L, H, T, S>` implements `Handler<T, S>`
|
|
||||||
`MethodRouter<S>` implements `Handler<(), S>`
|
|
||||||
note: required by a bound in `axum::routing::get`
|
note: required by a bound in `axum::routing::get`
|
||||||
--> $WORKSPACE/axum/src/routing/method_routing.rs
|
--> $WORKSPACE/axum/src/routing/method_routing.rs
|
||||||
|
|
|
|
||||||
|
|||||||
@@ -13,9 +13,6 @@ error[E0277]: the trait bound `fn(Extractor<()>) -> impl Future<Output = ()> {fo
|
|||||||
| required by a bound introduced by this call
|
| required by a bound introduced by this call
|
||||||
|
|
|
|
||||||
= note: Consider using `#[axum::debug_handler]` to improve the error message
|
= note: Consider using `#[axum::debug_handler]` to improve the error message
|
||||||
= help: the following other types implement trait `Handler<T, S>`:
|
|
||||||
`Layered<L, H, T, S>` implements `Handler<T, S>`
|
|
||||||
`MethodRouter<S>` implements `Handler<(), S>`
|
|
||||||
note: required by a bound in `axum::routing::get`
|
note: required by a bound in `axum::routing::get`
|
||||||
--> $WORKSPACE/axum/src/routing/method_routing.rs
|
--> $WORKSPACE/axum/src/routing/method_routing.rs
|
||||||
|
|
|
|
||||||
|
|||||||
@@ -13,9 +13,6 @@ error[E0277]: the trait bound `fn(MyExtractor) -> impl Future<Output = ()> {hand
|
|||||||
| required by a bound introduced by this call
|
| required by a bound introduced by this call
|
||||||
|
|
|
|
||||||
= note: Consider using `#[axum::debug_handler]` to improve the error message
|
= note: Consider using `#[axum::debug_handler]` to improve the error message
|
||||||
= help: the following other types implement trait `Handler<T, S>`:
|
|
||||||
`Layered<L, H, T, S>` implements `Handler<T, S>`
|
|
||||||
`MethodRouter<S>` implements `Handler<(), S>`
|
|
||||||
note: required by a bound in `axum::routing::get`
|
note: required by a bound in `axum::routing::get`
|
||||||
--> $WORKSPACE/axum/src/routing/method_routing.rs
|
--> $WORKSPACE/axum/src/routing/method_routing.rs
|
||||||
|
|
|
|
||||||
@@ -35,9 +32,6 @@ error[E0277]: the trait bound `fn(Result<MyExtractor, MyRejection>) -> impl Futu
|
|||||||
| required by a bound introduced by this call
|
| required by a bound introduced by this call
|
||||||
|
|
|
|
||||||
= note: Consider using `#[axum::debug_handler]` to improve the error message
|
= note: Consider using `#[axum::debug_handler]` to improve the error message
|
||||||
= help: the following other types implement trait `Handler<T, S>`:
|
|
||||||
`Layered<L, H, T, S>` implements `Handler<T, S>`
|
|
||||||
`MethodRouter<S>` implements `Handler<(), S>`
|
|
||||||
note: required by a bound in `MethodRouter::<S>::post`
|
note: required by a bound in `MethodRouter::<S>::post`
|
||||||
--> $WORKSPACE/axum/src/routing/method_routing.rs
|
--> $WORKSPACE/axum/src/routing/method_routing.rs
|
||||||
|
|
|
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ error[E0277]: the trait bound `String: FromRequestParts<_>` is not satisfied
|
|||||||
= note: Function argument is not a valid axum extractor.
|
= note: Function argument is not a valid axum extractor.
|
||||||
See `https://docs.rs/axum/0.8/axum/extract/index.html` for details
|
See `https://docs.rs/axum/0.8/axum/extract/index.html` for details
|
||||||
= help: the following other types implement trait `FromRequestParts<S>`:
|
= help: the following other types implement trait `FromRequestParts<S>`:
|
||||||
`()` implements `FromRequestParts<S>`
|
`ConnectInfo<T>` implements `FromRequestParts<S>`
|
||||||
`(T1, T2)` implements `FromRequestParts<S>`
|
`Extension<T>` implements `FromRequestParts<S>`
|
||||||
`(T1, T2, T3)` implements `FromRequestParts<S>`
|
`Extractor` implements `FromRequestParts<S>`
|
||||||
`(T1, T2, T3, T4)` implements `FromRequestParts<S>`
|
`HeaderMap` implements `FromRequestParts<S>`
|
||||||
`(T1, T2, T3, T4, T5)` implements `FromRequestParts<S>`
|
`MatchedPath` implements `FromRequestParts<S>`
|
||||||
`(T1, T2, T3, T4, T5, T6)` implements `FromRequestParts<S>`
|
`Method` implements `FromRequestParts<S>`
|
||||||
`(T1, T2, T3, T4, T5, T6, T7)` implements `FromRequestParts<S>`
|
`OriginalUri` implements `FromRequestParts<S>`
|
||||||
`(T1, T2, T3, T4, T5, T6, T7, T8)` implements `FromRequestParts<S>`
|
`Query<T>` implements `FromRequestParts<S>`
|
||||||
and $N others
|
and $N others
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ impl NestedPath {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[diagnostic::do_not_recommend] // pretty niche type
|
||||||
impl<S> FromRequestParts<S> for NestedPath
|
impl<S> FromRequestParts<S> for NestedPath
|
||||||
where
|
where
|
||||||
S: Send + Sync,
|
S: Send + Sync,
|
||||||
|
|||||||
@@ -204,6 +204,7 @@ pub trait Handler<T, S>: Clone + Send + Sync + Sized + 'static {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[diagnostic::do_not_recommend]
|
||||||
impl<F, Fut, Res, S> Handler<((),), S> for F
|
impl<F, Fut, Res, S> Handler<((),), S> for F
|
||||||
where
|
where
|
||||||
F: FnOnce() -> Fut + Clone + Send + Sync + 'static,
|
F: FnOnce() -> Fut + Clone + Send + Sync + 'static,
|
||||||
@@ -221,6 +222,7 @@ macro_rules! impl_handler {
|
|||||||
(
|
(
|
||||||
[$($ty:ident),*], $last:ident
|
[$($ty:ident),*], $last:ident
|
||||||
) => {
|
) => {
|
||||||
|
#[diagnostic::do_not_recommend]
|
||||||
#[allow(non_snake_case, unused_mut)]
|
#[allow(non_snake_case, unused_mut)]
|
||||||
impl<F, Fut, S, Res, M, $($ty,)* $last> Handler<(M, $($ty,)* $last,), S> for F
|
impl<F, Fut, S, Res, M, $($ty,)* $last> Handler<(M, $($ty,)* $last,), S> for F
|
||||||
where
|
where
|
||||||
@@ -265,6 +267,7 @@ mod private {
|
|||||||
pub enum IntoResponseHandler {}
|
pub enum IntoResponseHandler {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[diagnostic::do_not_recommend]
|
||||||
impl<T, S> Handler<private::IntoResponseHandler, S> for T
|
impl<T, S> Handler<private::IntoResponseHandler, S> for T
|
||||||
where
|
where
|
||||||
T: IntoResponse + Clone + Send + Sync + 'static,
|
T: IntoResponse + Clone + Send + Sync + 'static,
|
||||||
@@ -310,6 +313,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[diagnostic::do_not_recommend]
|
||||||
impl<H, S, T, L> Handler<T, S> for Layered<L, H, T, S>
|
impl<H, S, T, L> Handler<T, S> for Layered<L, H, T, S>
|
||||||
where
|
where
|
||||||
L: Layer<HandlerService<H, T, S>> + Clone + Send + Sync + 'static,
|
L: Layer<HandlerService<H, T, S>> + Clone + Send + Sync + 'static,
|
||||||
|
|||||||
@@ -1306,6 +1306,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[diagnostic::do_not_recommend]
|
||||||
impl<S> Handler<(), S> for MethodRouter<S>
|
impl<S> Handler<(), S> for MethodRouter<S>
|
||||||
where
|
where
|
||||||
S: Clone + 'static,
|
S: Clone + 'static,
|
||||||
|
|||||||
Reference in New Issue
Block a user