From 74eac39e0610d1f702fe297b84d04212c806738e Mon Sep 17 00:00:00 2001 From: AlphaKeks <85143381+AlphaKeks@users.noreply.github.com> Date: Tue, 9 Jul 2024 23:08:59 +0200 Subject: [PATCH] Fix clippy warning on `FromRef` derive macro (#2827) --- axum-macros/src/from_ref.rs | 2 +- .../tests/debug_handler/fail/json_not_deserialize.stderr | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/axum-macros/src/from_ref.rs b/axum-macros/src/from_ref.rs index 2ab69eb5..1a27765a 100644 --- a/axum-macros/src/from_ref.rs +++ b/axum-macros/src/from_ref.rs @@ -54,7 +54,7 @@ fn expand_field(state: &Ident, idx: usize, field: &Field) -> TokenStream { }; quote_spanned! {span=> - #[allow(clippy::clone_on_copy)] + #[allow(clippy::clone_on_copy, clippy::clone_on_ref_ptr)] impl ::axum::extract::FromRef<#state> for #field_ty { fn from_ref(state: &#state) -> Self { #body diff --git a/axum-macros/tests/debug_handler/fail/json_not_deserialize.stderr b/axum-macros/tests/debug_handler/fail/json_not_deserialize.stderr index 14b3ae83..945c66ff 100644 --- a/axum-macros/tests/debug_handler/fail/json_not_deserialize.stderr +++ b/axum-macros/tests/debug_handler/fail/json_not_deserialize.stderr @@ -4,6 +4,8 @@ error[E0277]: the trait bound `for<'de> Struct: serde::de::Deserialize<'de>` is 7 | async fn handler(_foo: Json) {} | ^^^^^^^^^^^^ the trait `for<'de> serde::de::Deserialize<'de>` is not implemented for `Struct`, which is required by `Json: FromRequest<()>` | + = note: for local types consider adding `#[derive(serde::Deserialize)]` to your `Struct` type + = note: for types from other crates check whether the crate offers a `serde` feature flag = help: the following other types implement trait `serde::de::Deserialize<'de>`: bool char @@ -25,6 +27,8 @@ error[E0277]: the trait bound `for<'de> Struct: serde::de::Deserialize<'de>` is 7 | async fn handler(_foo: Json) {} | ^^^^^^^^^^^^ the trait `for<'de> serde::de::Deserialize<'de>` is not implemented for `Struct`, which is required by `Json: FromRequest<()>` | + = note: for local types consider adding `#[derive(serde::Deserialize)]` to your `Struct` type + = note: for types from other crates check whether the crate offers a `serde` feature flag = help: the following other types implement trait `serde::de::Deserialize<'de>`: bool char