From 9ddb25f0897f7334e4e85ca26a81db272df1f02f Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Tue, 26 Nov 2024 19:04:01 +0100 Subject: [PATCH] Re-format trybuild tests (#3049) --- .../fail/multiple_request_consumers.rs | 6 +++++- .../fail/multiple_request_consumers.stderr | 12 ++++++------ .../debug_handler/fail/output_tuple_too_many.rs | 3 +-- .../fail/output_tuple_too_many.stderr | 14 +++++++------- .../fail/returning_request_parts.rs | 5 ++--- .../fail/returning_request_parts.stderr | 4 ++-- .../debug_handler/fail/too_many_extractors.rs | 5 +++-- .../tests/debug_handler/fail/wrong_order.rs | 2 +- .../debug_handler/fail/wrong_return_tuple.rs | 11 ++++------- .../fail/wrong_return_tuple.stderr | 12 ++++++------ .../debug_handler/pass/impl_into_response.rs | 2 +- .../tests/debug_handler/pass/infer_state.rs | 17 ++++------------- .../debug_handler/pass/multiple_extractors.rs | 2 +- axum-macros/tests/debug_handler/pass/ready.rs | 2 +- .../tests/debug_handler/pass/state_and_body.rs | 2 +- .../debug_middleware/fail/next_not_last.rs | 7 +------ .../debug_middleware/fail/next_not_last.stderr | 4 ++-- .../tests/debug_middleware/pass/basic.rs | 7 +------ axum-macros/tests/from_ref/pass/basic.rs | 10 ++++++---- .../fail/enum_from_request_ident_in_variant.rs | 2 +- .../state_infer_multiple_different_types.rs | 2 +- .../tests/from_request/pass/container_parts.rs | 2 +- axum-macros/tests/from_request/pass/named.rs | 9 +++------ .../tests/from_request/pass/named_parts.rs | 9 +++------ .../tests/from_request/pass/named_via.rs | 6 +++--- .../tests/from_request/pass/named_via_parts.rs | 6 +++--- .../pass/override_rejection_non_generic.rs | 7 ++----- .../override_rejection_non_generic_parts.rs | 7 ++----- .../override_rejection_with_via_on_struct.rs | 5 +---- ...erride_rejection_with_via_on_struct_parts.rs | 5 +---- .../tests/from_request/pass/state_cookie.rs | 4 ++-- .../tests/from_request/pass/state_explicit.rs | 4 ++-- .../from_request/pass/state_explicit_parts.rs | 6 +++--- .../from_request/pass/state_field_explicit.rs | 2 +- .../from_request/pass/state_field_infer.rs | 6 +----- .../tests/from_request/pass/state_infer.rs | 2 +- .../from_request/pass/state_infer_multiple.rs | 2 +- .../from_request/pass/state_infer_parts.rs | 2 +- .../tests/from_request/pass/state_via_infer.rs | 6 +----- .../from_request/pass/state_with_rejection.rs | 2 +- .../from_request/pass/tuple_same_type_twice.rs | 5 +---- .../pass/tuple_same_type_twice_parts.rs | 5 +---- .../tests/typed_path/fail/missing_field.rs | 3 +-- axum-macros/tests/typed_path/pass/into_uri.rs | 2 +- .../tests/typed_path/pass/option_result.rs | 2 +- .../tests/typed_path/pass/unit_struct.rs | 3 +-- .../tests/typed_path/pass/url_encoding.rs | 8 +------- 47 files changed, 97 insertions(+), 154 deletions(-) diff --git a/axum-macros/tests/debug_handler/fail/multiple_request_consumers.rs b/axum-macros/tests/debug_handler/fail/multiple_request_consumers.rs index 4c86ceae69..77235dfdb6 100644 --- a/axum-macros/tests/debug_handler/fail/multiple_request_consumers.rs +++ b/axum-macros/tests/debug_handler/fail/multiple_request_consumers.rs @@ -1,5 +1,9 @@ +use axum::{ + body::Bytes, + http::{Method, Uri}, + Json, +}; use axum_macros::debug_handler; -use axum::{Json, body::Bytes, http::{Method, Uri}}; #[debug_handler] async fn one(_: Json<()>, _: String, _: Uri) {} diff --git a/axum-macros/tests/debug_handler/fail/multiple_request_consumers.stderr b/axum-macros/tests/debug_handler/fail/multiple_request_consumers.stderr index ba2ff7adff..011ce89934 100644 --- a/axum-macros/tests/debug_handler/fail/multiple_request_consumers.stderr +++ b/axum-macros/tests/debug_handler/fail/multiple_request_consumers.stderr @@ -1,11 +1,11 @@ error: Can't have two extractors that consume the request body. `Json<_>` and `String` both do that. - --> tests/debug_handler/fail/multiple_request_consumers.rs:5:14 + --> tests/debug_handler/fail/multiple_request_consumers.rs:9:14 | -5 | async fn one(_: Json<()>, _: String, _: Uri) {} +9 | async fn one(_: Json<()>, _: String, _: Uri) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Can't have more than one extractor that consume the request body. `Json<_>`, `Bytes`, and `String` all do that. - --> tests/debug_handler/fail/multiple_request_consumers.rs:8:14 - | -8 | async fn two(_: Json<()>, _: Method, _: Bytes, _: Uri, _: String) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + --> tests/debug_handler/fail/multiple_request_consumers.rs:12:14 + | +12 | async fn two(_: Json<()>, _: Method, _: Bytes, _: Uri, _: String) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/axum-macros/tests/debug_handler/fail/output_tuple_too_many.rs b/axum-macros/tests/debug_handler/fail/output_tuple_too_many.rs index a6f1ba0866..ea15e66a37 100644 --- a/axum-macros/tests/debug_handler/fail/output_tuple_too_many.rs +++ b/axum-macros/tests/debug_handler/fail/output_tuple_too_many.rs @@ -1,8 +1,7 @@ use axum::response::AppendHeaders; #[axum::debug_handler] -async fn handler( -) -> ( +async fn handler() -> ( axum::http::StatusCode, AppendHeaders<[(axum::http::HeaderName, &'static str); 1]>, AppendHeaders<[(axum::http::HeaderName, &'static str); 1]>, diff --git a/axum-macros/tests/debug_handler/fail/output_tuple_too_many.stderr b/axum-macros/tests/debug_handler/fail/output_tuple_too_many.stderr index b6eb85079d..fb31388a4e 100644 --- a/axum-macros/tests/debug_handler/fail/output_tuple_too_many.stderr +++ b/axum-macros/tests/debug_handler/fail/output_tuple_too_many.stderr @@ -1,12 +1,12 @@ error: Cannot return tuples with more than 17 elements - --> tests/debug_handler/fail/output_tuple_too_many.rs:5:3 + --> tests/debug_handler/fail/output_tuple_too_many.rs:4:20 | -5 | ) -> ( - | ___^ -6 | | axum::http::StatusCode, +4 | async fn handler() -> ( + | ____________________^ +5 | | axum::http::StatusCode, +6 | | AppendHeaders<[(axum::http::HeaderName, &'static str); 1]>, 7 | | AppendHeaders<[(axum::http::HeaderName, &'static str); 1]>, -8 | | AppendHeaders<[(axum::http::HeaderName, &'static str); 1]>, ... | -24 | | axum::http::StatusCode, -25 | | ) { +23 | | axum::http::StatusCode, +24 | | ) { | |_^ diff --git a/axum-macros/tests/debug_handler/fail/returning_request_parts.rs b/axum-macros/tests/debug_handler/fail/returning_request_parts.rs index e29cba3f23..0658dc02bf 100644 --- a/axum-macros/tests/debug_handler/fail/returning_request_parts.rs +++ b/axum-macros/tests/debug_handler/fail/returning_request_parts.rs @@ -1,10 +1,9 @@ #[axum::debug_handler] -async fn handler( -) -> ( +async fn handler() -> ( axum::http::request::Parts, // this should be response parts, not request parts axum::http::StatusCode, ) { panic!() } -fn main(){} +fn main() {} diff --git a/axum-macros/tests/debug_handler/fail/returning_request_parts.stderr b/axum-macros/tests/debug_handler/fail/returning_request_parts.stderr index c3935ad52d..440f20fe58 100644 --- a/axum-macros/tests/debug_handler/fail/returning_request_parts.stderr +++ b/axum-macros/tests/debug_handler/fail/returning_request_parts.stderr @@ -1,7 +1,7 @@ error[E0308]: mismatched types - --> tests/debug_handler/fail/returning_request_parts.rs:4:5 + --> tests/debug_handler/fail/returning_request_parts.rs:3:5 | -4 | axum::http::request::Parts, // this should be response parts, not request parts +3 | axum::http::request::Parts, // this should be response parts, not request parts | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | expected `axum::http::response::Parts`, found `axum::http::request::Parts` diff --git a/axum-macros/tests/debug_handler/fail/too_many_extractors.rs b/axum-macros/tests/debug_handler/fail/too_many_extractors.rs index 441d0f0059..894a4e0d46 100644 --- a/axum-macros/tests/debug_handler/fail/too_many_extractors.rs +++ b/axum-macros/tests/debug_handler/fail/too_many_extractors.rs @@ -1,5 +1,5 @@ -use axum_macros::debug_handler; use axum::http::Uri; +use axum_macros::debug_handler; #[debug_handler] async fn handler( @@ -20,6 +20,7 @@ async fn handler( _e15: Uri, _e16: Uri, _e17: Uri, -) {} +) { +} fn main() {} diff --git a/axum-macros/tests/debug_handler/fail/wrong_order.rs b/axum-macros/tests/debug_handler/fail/wrong_order.rs index 7d22bf5251..8dfd73670f 100644 --- a/axum-macros/tests/debug_handler/fail/wrong_order.rs +++ b/axum-macros/tests/debug_handler/fail/wrong_order.rs @@ -1,5 +1,5 @@ +use axum::{http::Uri, Json}; use axum_macros::debug_handler; -use axum::{Json, http::Uri}; #[debug_handler] async fn one(_: Json<()>, _: Uri) {} diff --git a/axum-macros/tests/debug_handler/fail/wrong_return_tuple.rs b/axum-macros/tests/debug_handler/fail/wrong_return_tuple.rs index c2b4249520..0b2afa168e 100644 --- a/axum-macros/tests/debug_handler/fail/wrong_return_tuple.rs +++ b/axum-macros/tests/debug_handler/fail/wrong_return_tuple.rs @@ -4,16 +4,13 @@ async fn named_type() -> ( axum::http::StatusCode, axum::Json<&'static str>, - axum::response::AppendHeaders<[( axum::http::HeaderName,&'static str); 1]>, + axum::response::AppendHeaders<[(axum::http::HeaderName, &'static str); 1]>, ) { panic!() } - -struct CustomIntoResponse{ - -} -impl axum::response::IntoResponse for CustomIntoResponse{ +struct CustomIntoResponse {} +impl axum::response::IntoResponse for CustomIntoResponse { fn into_response(self) -> axum::response::Response { todo!() } @@ -22,7 +19,7 @@ impl axum::response::IntoResponse for CustomIntoResponse{ async fn custom_type() -> ( axum::http::StatusCode, CustomIntoResponse, - axum::response::AppendHeaders<[( axum::http::HeaderName,&'static str); 1]>, + axum::response::AppendHeaders<[(axum::http::HeaderName, &'static str); 1]>, ) { panic!() } diff --git a/axum-macros/tests/debug_handler/fail/wrong_return_tuple.stderr b/axum-macros/tests/debug_handler/fail/wrong_return_tuple.stderr index 77597b3358..8779d35805 100644 --- a/axum-macros/tests/debug_handler/fail/wrong_return_tuple.stderr +++ b/axum-macros/tests/debug_handler/fail/wrong_return_tuple.stderr @@ -5,9 +5,9 @@ error: `Json<_>` must be the last element in a response tuple | ^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `CustomIntoResponse: IntoResponseParts` is not satisfied - --> tests/debug_handler/fail/wrong_return_tuple.rs:24:5 + --> tests/debug_handler/fail/wrong_return_tuple.rs:21:5 | -24 | CustomIntoResponse, +21 | CustomIntoResponse, | ^^^^^^^^^^^^^^^^^^ the trait `IntoResponseParts` is not implemented for `CustomIntoResponse` | = help: the following other types implement trait `IntoResponseParts`: @@ -27,9 +27,9 @@ help: add `#![feature(trivial_bounds)]` to the crate attributes to enable | error[E0277]: the trait bound `CustomIntoResponse: IntoResponseParts` is not satisfied - --> tests/debug_handler/fail/wrong_return_tuple.rs:24:5 + --> tests/debug_handler/fail/wrong_return_tuple.rs:21:5 | -24 | CustomIntoResponse, +21 | CustomIntoResponse, | ^^^^^^^^^^^^^^^^^^ the trait `IntoResponseParts` is not implemented for `CustomIntoResponse` | = help: the following other types implement trait `IntoResponseParts`: @@ -43,7 +43,7 @@ error[E0277]: the trait bound `CustomIntoResponse: IntoResponseParts` is not sat (T1, T2, T3, T4, T5, T6, T7, T8) and $N others note: required by a bound in `__axum_macros_check_custom_type_into_response_parts_1_check` - --> tests/debug_handler/fail/wrong_return_tuple.rs:24:5 + --> tests/debug_handler/fail/wrong_return_tuple.rs:21:5 | -24 | CustomIntoResponse, +21 | CustomIntoResponse, | ^^^^^^^^^^^^^^^^^^ required by this bound in `__axum_macros_check_custom_type_into_response_parts_1_check` diff --git a/axum-macros/tests/debug_handler/pass/impl_into_response.rs b/axum-macros/tests/debug_handler/pass/impl_into_response.rs index 69b884e390..f15f29c4d0 100644 --- a/axum-macros/tests/debug_handler/pass/impl_into_response.rs +++ b/axum-macros/tests/debug_handler/pass/impl_into_response.rs @@ -1,5 +1,5 @@ -use axum_macros::debug_handler; use axum::response::IntoResponse; +use axum_macros::debug_handler; #[debug_handler] async fn handler() -> impl IntoResponse { diff --git a/axum-macros/tests/debug_handler/pass/infer_state.rs b/axum-macros/tests/debug_handler/pass/infer_state.rs index 9f21a8a626..fceeb78acc 100644 --- a/axum-macros/tests/debug_handler/pass/infer_state.rs +++ b/axum-macros/tests/debug_handler/pass/infer_state.rs @@ -1,5 +1,5 @@ -use axum_macros::debug_handler; use axum::extract::State; +use axum_macros::debug_handler; #[debug_handler] async fn handler(_: State) {} @@ -8,22 +8,13 @@ async fn handler(_: State) {} async fn handler_2(_: axum::extract::State) {} #[debug_handler] -async fn handler_3( - _: axum::extract::State, - _: axum::extract::State, -) {} +async fn handler_3(_: axum::extract::State, _: axum::extract::State) {} #[debug_handler] -async fn handler_4( - _: State, - _: State, -) {} +async fn handler_4(_: State, _: State) {} #[debug_handler] -async fn handler_5( - _: axum::extract::State, - _: State, -) {} +async fn handler_5(_: axum::extract::State, _: State) {} #[derive(Clone)] struct AppState; diff --git a/axum-macros/tests/debug_handler/pass/multiple_extractors.rs b/axum-macros/tests/debug_handler/pass/multiple_extractors.rs index 6cc05b5166..e54c43e61a 100644 --- a/axum-macros/tests/debug_handler/pass/multiple_extractors.rs +++ b/axum-macros/tests/debug_handler/pass/multiple_extractors.rs @@ -1,5 +1,5 @@ -use axum_macros::debug_handler; use axum::http::{Method, Uri}; +use axum_macros::debug_handler; #[debug_handler] async fn handler(_one: Method, _two: Uri, _three: String) {} diff --git a/axum-macros/tests/debug_handler/pass/ready.rs b/axum-macros/tests/debug_handler/pass/ready.rs index 4ee73e99c8..d705b8fefb 100644 --- a/axum-macros/tests/debug_handler/pass/ready.rs +++ b/axum-macros/tests/debug_handler/pass/ready.rs @@ -1,5 +1,5 @@ use axum_macros::debug_handler; -use std::future::{Ready, ready}; +use std::future::{ready, Ready}; #[debug_handler] fn handler() -> Ready<()> { diff --git a/axum-macros/tests/debug_handler/pass/state_and_body.rs b/axum-macros/tests/debug_handler/pass/state_and_body.rs index f348360b3a..629023aa03 100644 --- a/axum-macros/tests/debug_handler/pass/state_and_body.rs +++ b/axum-macros/tests/debug_handler/pass/state_and_body.rs @@ -1,5 +1,5 @@ +use axum::{extract::Request, extract::State}; use axum_macros::debug_handler; -use axum::{extract::State, extract::Request}; #[debug_handler(state = AppState)] async fn handler(_: State, _: Request) {} diff --git a/axum-macros/tests/debug_middleware/fail/next_not_last.rs b/axum-macros/tests/debug_middleware/fail/next_not_last.rs index 0108c85433..d2596ffb50 100644 --- a/axum-macros/tests/debug_middleware/fail/next_not_last.rs +++ b/axum-macros/tests/debug_middleware/fail/next_not_last.rs @@ -1,9 +1,4 @@ -use axum::{ - extract::Request, - response::Response, - middleware::Next, - debug_middleware, -}; +use axum::{debug_middleware, extract::Request, middleware::Next, response::Response}; #[debug_middleware] async fn my_middleware(next: Next, request: Request) -> Response { diff --git a/axum-macros/tests/debug_middleware/fail/next_not_last.stderr b/axum-macros/tests/debug_middleware/fail/next_not_last.stderr index 8f08bed72d..4a5fea4546 100644 --- a/axum-macros/tests/debug_middleware/fail/next_not_last.stderr +++ b/axum-macros/tests/debug_middleware/fail/next_not_last.stderr @@ -1,5 +1,5 @@ error: `axum::middleware::Next` must the last argument - --> tests/debug_middleware/fail/next_not_last.rs:9:24 + --> tests/debug_middleware/fail/next_not_last.rs:4:24 | -9 | async fn my_middleware(next: Next, request: Request) -> Response { +4 | async fn my_middleware(next: Next, request: Request) -> Response { | ^^^^^^^^^^ diff --git a/axum-macros/tests/debug_middleware/pass/basic.rs b/axum-macros/tests/debug_middleware/pass/basic.rs index 605cacfd40..1d2a412ac4 100644 --- a/axum-macros/tests/debug_middleware/pass/basic.rs +++ b/axum-macros/tests/debug_middleware/pass/basic.rs @@ -1,9 +1,4 @@ -use axum::{ - extract::Request, - response::Response, - middleware::Next, - debug_middleware, -}; +use axum::{debug_middleware, extract::Request, middleware::Next, response::Response}; #[debug_middleware] async fn my_middleware(request: Request, next: Next) -> Response { diff --git a/axum-macros/tests/from_ref/pass/basic.rs b/axum-macros/tests/from_ref/pass/basic.rs index e410e11a05..2b66d4064d 100644 --- a/axum-macros/tests/from_ref/pass/basic.rs +++ b/axum-macros/tests/from_ref/pass/basic.rs @@ -1,4 +1,8 @@ -use axum::{Router, routing::get, extract::{State, FromRef}}; +use axum::{ + extract::{FromRef, State}, + routing::get, + Router, +}; // This will implement `FromRef` for each field in the struct. #[derive(Clone, FromRef)] @@ -14,7 +18,5 @@ fn main() { auth_token: Default::default(), }; - let _: axum::Router = Router::new() - .route("/", get(handler)) - .with_state(state); + let _: axum::Router = Router::new().route("/", get(handler)).with_state(state); } diff --git a/axum-macros/tests/from_request/fail/enum_from_request_ident_in_variant.rs b/axum-macros/tests/from_request/fail/enum_from_request_ident_in_variant.rs index 336850e5a4..69942e4476 100644 --- a/axum-macros/tests/from_request/fail/enum_from_request_ident_in_variant.rs +++ b/axum-macros/tests/from_request/fail/enum_from_request_ident_in_variant.rs @@ -6,7 +6,7 @@ enum Extractor { Foo { #[from_request(via(axum::Extension))] foo: (), - } + }, } fn main() {} diff --git a/axum-macros/tests/from_request/fail/state_infer_multiple_different_types.rs b/axum-macros/tests/from_request/fail/state_infer_multiple_different_types.rs index 6533d3276a..18c0698f9f 100644 --- a/axum-macros/tests/from_request/fail/state_infer_multiple_different_types.rs +++ b/axum-macros/tests/from_request/fail/state_infer_multiple_different_types.rs @@ -1,5 +1,5 @@ -use axum_macros::FromRequest; use axum::extract::State; +use axum_macros::FromRequest; #[derive(FromRequest)] struct Extractor { diff --git a/axum-macros/tests/from_request/pass/container_parts.rs b/axum-macros/tests/from_request/pass/container_parts.rs index dedc1719a7..c90703d0fc 100644 --- a/axum-macros/tests/from_request/pass/container_parts.rs +++ b/axum-macros/tests/from_request/pass/container_parts.rs @@ -1,5 +1,5 @@ use axum::{ - extract::{FromRequestParts, Extension}, + extract::{Extension, FromRequestParts}, response::Response, }; diff --git a/axum-macros/tests/from_request/pass/named.rs b/axum-macros/tests/from_request/pass/named.rs index f63ae8e9db..d396847cce 100644 --- a/axum-macros/tests/from_request/pass/named.rs +++ b/axum-macros/tests/from_request/pass/named.rs @@ -1,11 +1,8 @@ -use axum::{ - extract::FromRequest, - response::Response, -}; +use axum::{extract::FromRequest, response::Response}; use axum_extra::{ - TypedHeader, - typed_header::TypedHeaderRejection, headers::{self, UserAgent}, + typed_header::TypedHeaderRejection, + TypedHeader, }; #[derive(FromRequest)] diff --git a/axum-macros/tests/from_request/pass/named_parts.rs b/axum-macros/tests/from_request/pass/named_parts.rs index cbb67e61da..1168b3a119 100644 --- a/axum-macros/tests/from_request/pass/named_parts.rs +++ b/axum-macros/tests/from_request/pass/named_parts.rs @@ -1,11 +1,8 @@ -use axum::{ - extract::FromRequestParts, - response::Response, -}; +use axum::{extract::FromRequestParts, response::Response}; use axum_extra::{ - TypedHeader, - typed_header::TypedHeaderRejection, headers::{self, UserAgent}, + typed_header::TypedHeaderRejection, + TypedHeader, }; #[derive(FromRequestParts)] diff --git a/axum-macros/tests/from_request/pass/named_via.rs b/axum-macros/tests/from_request/pass/named_via.rs index 691627b08d..5159c49b88 100644 --- a/axum-macros/tests/from_request/pass/named_via.rs +++ b/axum-macros/tests/from_request/pass/named_via.rs @@ -1,11 +1,11 @@ use axum::{ - response::Response, extract::{Extension, FromRequest}, + response::Response, }; use axum_extra::{ - TypedHeader, - typed_header::TypedHeaderRejection, headers::{self, UserAgent}, + typed_header::TypedHeaderRejection, + TypedHeader, }; #[derive(FromRequest)] diff --git a/axum-macros/tests/from_request/pass/named_via_parts.rs b/axum-macros/tests/from_request/pass/named_via_parts.rs index 0377af7b10..38fe0964c0 100644 --- a/axum-macros/tests/from_request/pass/named_via_parts.rs +++ b/axum-macros/tests/from_request/pass/named_via_parts.rs @@ -1,11 +1,11 @@ use axum::{ - response::Response, extract::{Extension, FromRequestParts}, + response::Response, }; use axum_extra::{ - TypedHeader, - typed_header::TypedHeaderRejection, headers::{self, UserAgent}, + typed_header::TypedHeaderRejection, + TypedHeader, }; #[derive(FromRequestParts)] diff --git a/axum-macros/tests/from_request/pass/override_rejection_non_generic.rs b/axum-macros/tests/from_request/pass/override_rejection_non_generic.rs index 6c4d87fe01..b88b483e3b 100644 --- a/axum-macros/tests/from_request/pass/override_rejection_non_generic.rs +++ b/axum-macros/tests/from_request/pass/override_rejection_non_generic.rs @@ -5,8 +5,8 @@ use axum::{ Router, }; use axum_macros::FromRequest; -use std::collections::HashMap; use serde::Deserialize; +use std::collections::HashMap; fn main() { let _: Router = Router::new().route("/", get(handler).post(handler_result)); @@ -17,10 +17,7 @@ async fn handler(_: MyJson) {} async fn handler_result(_: Result) {} #[derive(FromRequest, Deserialize)] -#[from_request( - via(axum::extract::Json), - rejection(MyJsonRejection), -)] +#[from_request(via(axum::extract::Json), rejection(MyJsonRejection))] #[serde(transparent)] struct MyJson(HashMap); diff --git a/axum-macros/tests/from_request/pass/override_rejection_non_generic_parts.rs b/axum-macros/tests/from_request/pass/override_rejection_non_generic_parts.rs index 9aca7345dd..bcf213d1e2 100644 --- a/axum-macros/tests/from_request/pass/override_rejection_non_generic_parts.rs +++ b/axum-macros/tests/from_request/pass/override_rejection_non_generic_parts.rs @@ -5,8 +5,8 @@ use axum::{ Router, }; use axum_macros::FromRequestParts; -use std::collections::HashMap; use serde::Deserialize; +use std::collections::HashMap; fn main() { let _: Router = Router::new().route("/", get(handler).post(handler_result)); @@ -17,10 +17,7 @@ async fn handler(_: MyQuery) {} async fn handler_result(_: Result) {} #[derive(FromRequestParts, Deserialize)] -#[from_request( - via(axum::extract::Query), - rejection(MyQueryRejection), -)] +#[from_request(via(axum::extract::Query), rejection(MyQueryRejection))] #[serde(transparent)] struct MyQuery(HashMap); diff --git a/axum-macros/tests/from_request/pass/override_rejection_with_via_on_struct.rs b/axum-macros/tests/from_request/pass/override_rejection_with_via_on_struct.rs index 2a046fae50..8dab4165e4 100644 --- a/axum-macros/tests/from_request/pass/override_rejection_with_via_on_struct.rs +++ b/axum-macros/tests/from_request/pass/override_rejection_with_via_on_struct.rs @@ -19,10 +19,7 @@ async fn handler(_: MyJson) {} async fn handler_result(_: Result, MyJsonRejection>) {} #[derive(FromRequest)] -#[from_request( - via(axum::Json), - rejection(MyJsonRejection), -)] +#[from_request(via(axum::Json), rejection(MyJsonRejection))] struct MyJson(T); struct MyJsonRejection {} diff --git a/axum-macros/tests/from_request/pass/override_rejection_with_via_on_struct_parts.rs b/axum-macros/tests/from_request/pass/override_rejection_with_via_on_struct_parts.rs index eaeeeacf23..19e7307678 100644 --- a/axum-macros/tests/from_request/pass/override_rejection_with_via_on_struct_parts.rs +++ b/axum-macros/tests/from_request/pass/override_rejection_with_via_on_struct_parts.rs @@ -19,10 +19,7 @@ async fn handler(_: MyQuery) {} async fn handler_result(_: Result, MyQueryRejection>) {} #[derive(FromRequestParts)] -#[from_request( - via(axum::extract::Query), - rejection(MyQueryRejection), -)] +#[from_request(via(axum::extract::Query), rejection(MyQueryRejection))] struct MyQuery(T); struct MyQueryRejection {} diff --git a/axum-macros/tests/from_request/pass/state_cookie.rs b/axum-macros/tests/from_request/pass/state_cookie.rs index 6e2aa1f4ed..ce935d67fa 100644 --- a/axum-macros/tests/from_request/pass/state_cookie.rs +++ b/axum-macros/tests/from_request/pass/state_cookie.rs @@ -1,6 +1,6 @@ -use axum_macros::FromRequest; use axum::extract::FromRef; -use axum_extra::extract::cookie::{PrivateCookieJar, Key}; +use axum_extra::extract::cookie::{Key, PrivateCookieJar}; +use axum_macros::FromRequest; #[derive(FromRequest)] #[from_request(state(AppState))] diff --git a/axum-macros/tests/from_request/pass/state_explicit.rs b/axum-macros/tests/from_request/pass/state_explicit.rs index aed9dad6d5..df32a72568 100644 --- a/axum-macros/tests/from_request/pass/state_explicit.rs +++ b/axum-macros/tests/from_request/pass/state_explicit.rs @@ -1,9 +1,9 @@ -use axum_macros::FromRequest; use axum::{ extract::{FromRef, State}, - Router, routing::get, + Router, }; +use axum_macros::FromRequest; fn main() { let _: axum::Router = Router::new() diff --git a/axum-macros/tests/from_request/pass/state_explicit_parts.rs b/axum-macros/tests/from_request/pass/state_explicit_parts.rs index 94f37cf6b8..2822699379 100644 --- a/axum-macros/tests/from_request/pass/state_explicit_parts.rs +++ b/axum-macros/tests/from_request/pass/state_explicit_parts.rs @@ -1,9 +1,9 @@ -use axum_macros::FromRequestParts; use axum::{ - extract::{FromRef, State, Query}, - Router, + extract::{FromRef, Query, State}, routing::get, + Router, }; +use axum_macros::FromRequestParts; use std::collections::HashMap; fn main() { diff --git a/axum-macros/tests/from_request/pass/state_field_explicit.rs b/axum-macros/tests/from_request/pass/state_field_explicit.rs index b6d003dc00..90a903261e 100644 --- a/axum-macros/tests/from_request/pass/state_field_explicit.rs +++ b/axum-macros/tests/from_request/pass/state_field_explicit.rs @@ -1,5 +1,5 @@ use axum::{ - extract::{State, FromRef}, + extract::{FromRef, State}, routing::get, Router, }; diff --git a/axum-macros/tests/from_request/pass/state_field_infer.rs b/axum-macros/tests/from_request/pass/state_field_infer.rs index a24861a162..5e399c1bf0 100644 --- a/axum-macros/tests/from_request/pass/state_field_infer.rs +++ b/axum-macros/tests/from_request/pass/state_field_infer.rs @@ -1,8 +1,4 @@ -use axum::{ - extract::State, - routing::get, - Router, -}; +use axum::{extract::State, routing::get, Router}; use axum_macros::FromRequest; fn main() { diff --git a/axum-macros/tests/from_request/pass/state_infer.rs b/axum-macros/tests/from_request/pass/state_infer.rs index 07545ab074..39966b7c9b 100644 --- a/axum-macros/tests/from_request/pass/state_infer.rs +++ b/axum-macros/tests/from_request/pass/state_infer.rs @@ -1,5 +1,5 @@ -use axum_macros::FromRequest; use axum::extract::State; +use axum_macros::FromRequest; #[derive(FromRequest)] struct Extractor { diff --git a/axum-macros/tests/from_request/pass/state_infer_multiple.rs b/axum-macros/tests/from_request/pass/state_infer_multiple.rs index cb8de1d59c..d727a7e337 100644 --- a/axum-macros/tests/from_request/pass/state_infer_multiple.rs +++ b/axum-macros/tests/from_request/pass/state_infer_multiple.rs @@ -1,5 +1,5 @@ -use axum_macros::FromRequest; use axum::extract::State; +use axum_macros::FromRequest; #[derive(FromRequest)] struct Extractor { diff --git a/axum-macros/tests/from_request/pass/state_infer_parts.rs b/axum-macros/tests/from_request/pass/state_infer_parts.rs index f3f078c5f3..35ffcc31f0 100644 --- a/axum-macros/tests/from_request/pass/state_infer_parts.rs +++ b/axum-macros/tests/from_request/pass/state_infer_parts.rs @@ -1,5 +1,5 @@ -use axum_macros::FromRequestParts; use axum::extract::State; +use axum_macros::FromRequestParts; #[derive(FromRequestParts)] struct Extractor { diff --git a/axum-macros/tests/from_request/pass/state_via_infer.rs b/axum-macros/tests/from_request/pass/state_via_infer.rs index 40c52d8d4d..685ff1c7fe 100644 --- a/axum-macros/tests/from_request/pass/state_via_infer.rs +++ b/axum-macros/tests/from_request/pass/state_via_infer.rs @@ -1,8 +1,4 @@ -use axum::{ - extract::State, - routing::get, - Router, -}; +use axum::{extract::State, routing::get, Router}; use axum_macros::FromRequest; fn main() { diff --git a/axum-macros/tests/from_request/pass/state_with_rejection.rs b/axum-macros/tests/from_request/pass/state_with_rejection.rs index 9921add02b..8e730c961e 100644 --- a/axum-macros/tests/from_request/pass/state_with_rejection.rs +++ b/axum-macros/tests/from_request/pass/state_with_rejection.rs @@ -1,4 +1,3 @@ -use std::convert::Infallible; use axum::{ extract::State, response::{IntoResponse, Response}, @@ -6,6 +5,7 @@ use axum::{ Router, }; use axum_macros::FromRequest; +use std::convert::Infallible; fn main() { let _: axum::Router = Router::new() diff --git a/axum-macros/tests/from_request/pass/tuple_same_type_twice.rs b/axum-macros/tests/from_request/pass/tuple_same_type_twice.rs index 343563ddb6..56c8fd0f12 100644 --- a/axum-macros/tests/from_request/pass/tuple_same_type_twice.rs +++ b/axum-macros/tests/from_request/pass/tuple_same_type_twice.rs @@ -3,10 +3,7 @@ use axum_macros::FromRequest; use serde::Deserialize; #[derive(FromRequest)] -struct Extractor( - Query, - axum::extract::Json, -); +struct Extractor(Query, axum::extract::Json); #[derive(Deserialize)] struct Payload {} diff --git a/axum-macros/tests/from_request/pass/tuple_same_type_twice_parts.rs b/axum-macros/tests/from_request/pass/tuple_same_type_twice_parts.rs index 44c42dc5ab..a781baf605 100644 --- a/axum-macros/tests/from_request/pass/tuple_same_type_twice_parts.rs +++ b/axum-macros/tests/from_request/pass/tuple_same_type_twice_parts.rs @@ -3,10 +3,7 @@ use axum_macros::FromRequestParts; use serde::Deserialize; #[derive(FromRequestParts)] -struct Extractor( - Query, - axum::extract::Path, -); +struct Extractor(Query, axum::extract::Path); #[derive(Deserialize)] struct Payload {} diff --git a/axum-macros/tests/typed_path/fail/missing_field.rs b/axum-macros/tests/typed_path/fail/missing_field.rs index 6991ed1643..7f1f3be06d 100644 --- a/axum-macros/tests/typed_path/fail/missing_field.rs +++ b/axum-macros/tests/typed_path/fail/missing_field.rs @@ -5,5 +5,4 @@ use serde::Deserialize; #[typed_path("/users/{id}")] struct MyPath {} -fn main() { -} +fn main() {} diff --git a/axum-macros/tests/typed_path/pass/into_uri.rs b/axum-macros/tests/typed_path/pass/into_uri.rs index 2269b53133..20b01c1d57 100644 --- a/axum-macros/tests/typed_path/pass/into_uri.rs +++ b/axum-macros/tests/typed_path/pass/into_uri.rs @@ -1,5 +1,5 @@ -use axum_extra::routing::TypedPath; use axum::http::Uri; +use axum_extra::routing::TypedPath; use serde::Deserialize; #[derive(TypedPath, Deserialize)] diff --git a/axum-macros/tests/typed_path/pass/option_result.rs b/axum-macros/tests/typed_path/pass/option_result.rs index 36ea33707e..81cfb29482 100644 --- a/axum-macros/tests/typed_path/pass/option_result.rs +++ b/axum-macros/tests/typed_path/pass/option_result.rs @@ -1,5 +1,5 @@ -use axum_extra::routing::{TypedPath, RouterExt}; use axum::{extract::rejection::PathRejection, http::StatusCode}; +use axum_extra::routing::{RouterExt, TypedPath}; use serde::Deserialize; #[derive(TypedPath, Deserialize)] diff --git a/axum-macros/tests/typed_path/pass/unit_struct.rs b/axum-macros/tests/typed_path/pass/unit_struct.rs index f3bb164075..832e1001d3 100644 --- a/axum-macros/tests/typed_path/pass/unit_struct.rs +++ b/axum-macros/tests/typed_path/pass/unit_struct.rs @@ -5,8 +5,7 @@ use axum_extra::routing::TypedPath; struct MyPath; fn main() { - _ = axum::Router::<()>::new() - .route("/", axum::routing::get(|_: MyPath| async {})); + _ = axum::Router::<()>::new().route("/", axum::routing::get(|_: MyPath| async {})); assert_eq!(MyPath::PATH, "/users"); assert_eq!(format!("{}", MyPath), "/users"); diff --git a/axum-macros/tests/typed_path/pass/url_encoding.rs b/axum-macros/tests/typed_path/pass/url_encoding.rs index 5ac412e447..5e773d698e 100644 --- a/axum-macros/tests/typed_path/pass/url_encoding.rs +++ b/axum-macros/tests/typed_path/pass/url_encoding.rs @@ -22,11 +22,5 @@ fn main() { "/a%20b" ); - assert_eq!( - format!( - "{}", - Unnamed("a b".to_string()), - ), - "/a%20b" - ); + assert_eq!(format!("{}", Unnamed("a b".to_string()),), "/a%20b"); }