From 34e11c50b5cc1ae9015c00cd9091436f8fe0d9db Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Sun, 9 Jun 2024 20:17:43 +0200 Subject: [PATCH] Add Extension debug_handler ui test (#2731) Co-authored-by: Logan Nielsen --- .../debug_handler/fail/extension_not_clone.rs | 9 ++++++ .../fail/extension_not_clone.stderr | 28 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 axum-macros/tests/debug_handler/fail/extension_not_clone.rs create mode 100644 axum-macros/tests/debug_handler/fail/extension_not_clone.stderr diff --git a/axum-macros/tests/debug_handler/fail/extension_not_clone.rs b/axum-macros/tests/debug_handler/fail/extension_not_clone.rs new file mode 100644 index 00000000..6bed79e1 --- /dev/null +++ b/axum-macros/tests/debug_handler/fail/extension_not_clone.rs @@ -0,0 +1,9 @@ +use axum::extract::Extension; +use axum_macros::debug_handler; + +struct NonCloneType; + +#[debug_handler] +async fn test_extension_non_clone(_: Extension) {} + +fn main() {} diff --git a/axum-macros/tests/debug_handler/fail/extension_not_clone.stderr b/axum-macros/tests/debug_handler/fail/extension_not_clone.stderr new file mode 100644 index 00000000..1e80461b --- /dev/null +++ b/axum-macros/tests/debug_handler/fail/extension_not_clone.stderr @@ -0,0 +1,28 @@ +error[E0277]: the trait bound `NonCloneType: Clone` is not satisfied + --> tests/debug_handler/fail/extension_not_clone.rs:7:38 + | +7 | async fn test_extension_non_clone(_: Extension) {} + | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `NonCloneType`, which is required by `Extension: FromRequest<(), _>` + | + = help: the following other types implement trait `FromRequest`: + axum::body::Bytes + Body + Form + Json + axum::http::Request + RawForm + String + Option + and $N others + = note: required for `Extension` to implement `FromRequestParts<()>` + = note: required for `Extension` 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` + --> tests/debug_handler/fail/extension_not_clone.rs:7:38 + | +7 | async fn test_extension_non_clone(_: Extension) {} + | ^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `__axum_macros_check_test_extension_non_clone_0_from_request_check` +help: consider annotating `NonCloneType` with `#[derive(Clone)]` + | +4 + #[derive(Clone)] +5 | struct NonCloneType; + |