mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-29 00:00:18 +02:00
Improve compile errors for unimplemented traits (#1436)
* Improve `debug_handler` to use the correct span for specific bounds This results in better localised error messages, as they now point directly to the corresponding argument instead of to the macro itself. * Improve some error messages behind a `nightly-error-messages` feature flag This uses the nightly only `rustc_on_unimplemented` attribute to improve some error messages when users try to use invalid handler functions. This should be seen as prove of concept, not as full solution for all potential error cases. The underlying feature is currently marked as permanently unstable, but I'm working on getting this specific attribute (or an attribute with different name, similar functionality) ready to work on a stable compiler. * Apply suggestions from code review Co-authored-by: Jonas Platte <[email protected]> * Enable the `nightly-error-messages` feature unconditionally for nightly compilers * Use a nightly compiler to run the axum-marcos compile fail tests * update to newer nightly * Run axum-macros tests on nightly * tweak compile error hints a bit * more tweaks * update test Co-authored-by: Jonas Platte <[email protected]> Co-authored-by: David Pedersen <[email protected]>
This commit is contained in:
co-authored by
Jonas Platte
David Pedersen
parent
2e3000f1a3
commit
d5de3bc7e3
@@ -12,6 +12,7 @@ error[E0277]: the trait bound `fn(Extractor<()>) -> impl Future<Output = ()> {fo
|
||||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
= note: Consider using `#[axum::debug_handler]` to improve the error message
|
||||
= help: the trait `Handler<T, S, B2>` is implemented for `Layered<L, H, T, S, B, B2>`
|
||||
note: required by a bound in `axum::routing::get`
|
||||
--> $WORKSPACE/axum/src/routing/method_routing.rs
|
||||
|
||||
@@ -12,6 +12,7 @@ error[E0277]: the trait bound `fn(Extractor<()>) -> impl Future<Output = ()> {fo
|
||||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
= note: Consider using `#[axum::debug_handler]` to improve the error message
|
||||
= help: the trait `Handler<T, S, B2>` is implemented for `Layered<L, H, T, S, B, B2>`
|
||||
note: required by a bound in `axum::routing::get`
|
||||
--> $WORKSPACE/axum/src/routing/method_routing.rs
|
||||
|
||||
@@ -12,6 +12,7 @@ error[E0277]: the trait bound `fn(MyExtractor) -> impl Future<Output = ()> {hand
|
||||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
= note: Consider using `#[axum::debug_handler]` to improve the error message
|
||||
= help: the trait `Handler<T, S, B2>` is implemented for `Layered<L, H, T, S, B, B2>`
|
||||
note: required by a bound in `axum::routing::get`
|
||||
--> $WORKSPACE/axum/src/routing/method_routing.rs
|
||||
@@ -28,6 +29,7 @@ error[E0277]: the trait bound `fn(Result<MyExtractor, MyRejection>) -> impl Futu
|
||||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
= note: Consider using `#[axum::debug_handler]` to improve the error message
|
||||
= help: the trait `Handler<T, S, B2>` is implemented for `Layered<L, H, T, S, B, B2>`
|
||||
note: required by a bound in `MethodRouter::<S, B>::post`
|
||||
--> $WORKSPACE/axum/src/routing/method_routing.rs
|
||||
|
||||
@@ -4,6 +4,8 @@ error[E0277]: the trait bound `String: FromRequestParts<S>` is not satisfied
|
||||
5 | body: String,
|
||||
| ^^^^^^ the trait `FromRequestParts<S>` is not implemented for `String`
|
||||
|
|
||||
= note: Function argument is not a valid axum extractor.
|
||||
See `https://docs.rs/axum/latest/axum/extract/index.html` for details
|
||||
= help: the following other types implement trait `FromRequestParts<S>`:
|
||||
<() as FromRequestParts<S>>
|
||||
<(T1, T2) as FromRequestParts<S>>
|
||||
|
||||
Reference in New Issue
Block a user