From 58ba5a24507072781dbcb96e6787196746cd97d4 Mon Sep 17 00:00:00 2001 From: David Pedersen Date: Mon, 14 Feb 2022 14:49:55 +0100 Subject: [PATCH] Update span for `FromRequest` impls to point to callsite --- axum-macros/src/typed_path.rs | 2 +- axum-macros/tests/typed_path/fail/not_deserialize.stderr | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/axum-macros/src/typed_path.rs b/axum-macros/src/typed_path.rs index e14d4d32..f4f15529 100644 --- a/axum-macros/src/typed_path.rs +++ b/axum-macros/src/typed_path.rs @@ -84,7 +84,7 @@ fn expand_named_fields(ident: &syn::Ident, path: LitStr, segments: &[Segment]) - } }; - let from_request_impl = quote_spanned! {path.span()=> + let from_request_impl = quote! { #[::axum::async_trait] #[automatically_derived] impl ::axum::extract::FromRequest for #ident diff --git a/axum-macros/tests/typed_path/fail/not_deserialize.stderr b/axum-macros/tests/typed_path/fail/not_deserialize.stderr index e4a3b734..3c6f6258 100644 --- a/axum-macros/tests/typed_path/fail/not_deserialize.stderr +++ b/axum-macros/tests/typed_path/fail/not_deserialize.stderr @@ -1,8 +1,9 @@ error[E0277]: the trait bound `for<'de> MyPath: serde::de::Deserialize<'de>` is not satisfied - --> tests/typed_path/fail/not_deserialize.rs:4:14 + --> tests/typed_path/fail/not_deserialize.rs:3:10 | -4 | #[typed_path("/users/:id")] - | ^^^^^^^^^^^^ the trait `for<'de> serde::de::Deserialize<'de>` is not implemented for `MyPath` +3 | #[derive(TypedPath)] + | ^^^^^^^^^ the trait `for<'de> serde::de::Deserialize<'de>` is not implemented for `MyPath` | = note: required because of the requirements on the impl of `serde::de::DeserializeOwned` for `MyPath` = note: required because of the requirements on the impl of `FromRequest` for `axum::extract::Path` + = note: this error originates in the derive macro `TypedPath` (in Nightly builds, run with -Z macro-backtrace for more info)