Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-format trybuild tests #3049

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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) {}
Expand Down
Original file line number Diff line number Diff line change
@@ -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) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Original file line number Diff line number Diff line change
@@ -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]>,
Expand Down
Original file line number Diff line number Diff line change
@@ -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 | | ) {
| |_^
Original file line number Diff line number Diff line change
@@ -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() {}
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
5 changes: 3 additions & 2 deletions axum-macros/tests/debug_handler/fail/too_many_extractors.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use axum_macros::debug_handler;
use axum::http::Uri;
use axum_macros::debug_handler;

#[debug_handler]
async fn handler(
Expand All @@ -20,6 +20,7 @@ async fn handler(
_e15: Uri,
_e16: Uri,
_e17: Uri,
) {}
) {
}

fn main() {}
2 changes: 1 addition & 1 deletion axum-macros/tests/debug_handler/fail/wrong_order.rs
Original file line number Diff line number Diff line change
@@ -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) {}
Expand Down
11 changes: 4 additions & 7 deletions axum-macros/tests/debug_handler/fail/wrong_return_tuple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!()
}
Expand All @@ -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!()
}
Expand Down
12 changes: 6 additions & 6 deletions axum-macros/tests/debug_handler/fail/wrong_return_tuple.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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`:
Expand All @@ -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`:
Expand All @@ -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`
2 changes: 1 addition & 1 deletion axum-macros/tests/debug_handler/pass/impl_into_response.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
17 changes: 4 additions & 13 deletions axum-macros/tests/debug_handler/pass/infer_state.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use axum_macros::debug_handler;
use axum::extract::State;
use axum_macros::debug_handler;

#[debug_handler]
async fn handler(_: State<AppState>) {}
Expand All @@ -8,22 +8,13 @@ async fn handler(_: State<AppState>) {}
async fn handler_2(_: axum::extract::State<AppState>) {}

#[debug_handler]
async fn handler_3(
_: axum::extract::State<AppState>,
_: axum::extract::State<AppState>,
) {}
async fn handler_3(_: axum::extract::State<AppState>, _: axum::extract::State<AppState>) {}

#[debug_handler]
async fn handler_4(
_: State<AppState>,
_: State<AppState>,
) {}
async fn handler_4(_: State<AppState>, _: State<AppState>) {}

#[debug_handler]
async fn handler_5(
_: axum::extract::State<AppState>,
_: State<AppState>,
) {}
async fn handler_5(_: axum::extract::State<AppState>, _: State<AppState>) {}

#[derive(Clone)]
struct AppState;
Expand Down
Original file line number Diff line number Diff line change
@@ -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) {}
Expand Down
2 changes: 1 addition & 1 deletion axum-macros/tests/debug_handler/pass/ready.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use axum_macros::debug_handler;
use std::future::{Ready, ready};
use std::future::{ready, Ready};

#[debug_handler]
fn handler() -> Ready<()> {
Expand Down
2 changes: 1 addition & 1 deletion axum-macros/tests/debug_handler/pass/state_and_body.rs
Original file line number Diff line number Diff line change
@@ -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<AppState>, _: Request) {}
Expand Down
7 changes: 1 addition & 6 deletions axum-macros/tests/debug_middleware/fail/next_not_last.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions axum-macros/tests/debug_middleware/fail/next_not_last.stderr
Original file line number Diff line number Diff line change
@@ -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 {
| ^^^^^^^^^^
7 changes: 1 addition & 6 deletions axum-macros/tests/debug_middleware/pass/basic.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
10 changes: 6 additions & 4 deletions axum-macros/tests/from_ref/pass/basic.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand All @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ enum Extractor {
Foo {
#[from_request(via(axum::Extension))]
foo: (),
}
},
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use axum_macros::FromRequest;
use axum::extract::State;
use axum_macros::FromRequest;

#[derive(FromRequest)]
struct Extractor {
Expand Down
2 changes: 1 addition & 1 deletion axum-macros/tests/from_request/pass/container_parts.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use axum::{
extract::{FromRequestParts, Extension},
extract::{Extension, FromRequestParts},
response::Response,
};

Expand Down
9 changes: 3 additions & 6 deletions axum-macros/tests/from_request/pass/named.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
9 changes: 3 additions & 6 deletions axum-macros/tests/from_request/pass/named_parts.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
6 changes: 3 additions & 3 deletions axum-macros/tests/from_request/pass/named_via.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
6 changes: 3 additions & 3 deletions axum-macros/tests/from_request/pass/named_via_parts.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -17,10 +17,7 @@ async fn handler(_: MyJson) {}
async fn handler_result(_: Result<MyJson, MyJsonRejection>) {}

#[derive(FromRequest, Deserialize)]
#[from_request(
via(axum::extract::Json),
rejection(MyJsonRejection),
)]
#[from_request(via(axum::extract::Json), rejection(MyJsonRejection))]
#[serde(transparent)]
struct MyJson(HashMap<String, String>);

Expand Down
Loading