Remove B type param (#1751)

Co-authored-by: Jonas Platte <[email protected]>
Co-authored-by: Michael Scofield <[email protected]>
This commit is contained in:
David Pedersen
2023-04-21 17:45:31 +02:00
co-authored by Jonas Platte Michael Scofield
parent 9be0ea934c
commit 4e4c29175f
100 changed files with 966 additions and 1160 deletions
@@ -1,4 +1,4 @@
use axum::{body::Body, routing::get, Router};
use axum::{routing::get, Router};
use axum_macros::FromRequest;
#[derive(FromRequest, Clone)]
@@ -7,5 +7,5 @@ struct Extractor<T>(T);
async fn foo(_: Extractor<()>) {}
fn main() {
Router::<(), Body>::new().route("/", get(foo));
_ = Router::<()>::new().route("/", get(foo));
}
@@ -4,21 +4,21 @@ error: #[derive(FromRequest)] only supports generics when used with #[from_reque
5 | struct Extractor<T>(T);
| ^
error[E0277]: the trait bound `fn(Extractor<()>) -> impl Future<Output = ()> {foo}: Handler<_, _, _>` is not satisfied
--> tests/from_request/fail/generic_without_via.rs:10:46
|
10 | Router::<(), Body>::new().route("/", get(foo));
| --- ^^^ the trait `Handler<_, _, _>` is not implemented for fn item `fn(Extractor<()>) -> impl Future<Output = ()> {foo}`
| |
| required by a bound introduced by this call
|
= note: Consider using `#[axum::debug_handler]` to improve the error message
= help: the following other types implement trait `Handler<T, S, B>`:
<Layered<L, H, T, S, B, B2> as Handler<T, S, B2>>
<MethodRouter<S, B> as Handler<(), S, B>>
error[E0277]: the trait bound `fn(Extractor<()>) -> impl Future<Output = ()> {foo}: Handler<_, _>` is not satisfied
--> tests/from_request/fail/generic_without_via.rs:10:44
|
10 | _ = Router::<()>::new().route("/", get(foo));
| --- ^^^ the trait `Handler<_, _>` is not implemented for fn item `fn(Extractor<()>) -> impl Future<Output = ()> {foo}`
| |
| required by a bound introduced by this call
|
= note: Consider using `#[axum::debug_handler]` to improve the error message
= help: the following other types implement trait `Handler<T, S>`:
<Layered<L, H, T, S> as Handler<T, S>>
<MethodRouter<S> as Handler<(), S>>
note: required by a bound in `axum::routing::get`
--> $WORKSPACE/axum/src/routing/method_routing.rs
|
| top_level_handler_fn!(get, GET);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `axum::routing::get`
= note: this error originates in the macro `top_level_handler_fn` (in Nightly builds, run with -Z macro-backtrace for more info)
--> $WORKSPACE/axum/src/routing/method_routing.rs
|
| top_level_handler_fn!(get, GET);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `axum::routing::get`
= note: this error originates in the macro `top_level_handler_fn` (in Nightly builds, run with -Z macro-backtrace for more info)
@@ -1,4 +1,4 @@
use axum::{body::Body, routing::get, Router};
use axum::{routing::get, Router};
use axum_macros::FromRequest;
#[derive(FromRequest, Clone)]
@@ -8,5 +8,5 @@ struct Extractor<T>(T);
async fn foo(_: Extractor<()>) {}
fn main() {
Router::<(), Body>::new().route("/", get(foo));
_ = Router::<()>::new().route("/", get(foo));
}
@@ -4,21 +4,21 @@ error: #[derive(FromRequest)] only supports generics when used with #[from_reque
6 | struct Extractor<T>(T);
| ^
error[E0277]: the trait bound `fn(Extractor<()>) -> impl Future<Output = ()> {foo}: Handler<_, _, _>` is not satisfied
--> tests/from_request/fail/generic_without_via_rejection.rs:11:46
|
11 | Router::<(), Body>::new().route("/", get(foo));
| --- ^^^ the trait `Handler<_, _, _>` is not implemented for fn item `fn(Extractor<()>) -> impl Future<Output = ()> {foo}`
| |
| required by a bound introduced by this call
|
= note: Consider using `#[axum::debug_handler]` to improve the error message
= help: the following other types implement trait `Handler<T, S, B>`:
<Layered<L, H, T, S, B, B2> as Handler<T, S, B2>>
<MethodRouter<S, B> as Handler<(), S, B>>
error[E0277]: the trait bound `fn(Extractor<()>) -> impl Future<Output = ()> {foo}: Handler<_, _>` is not satisfied
--> tests/from_request/fail/generic_without_via_rejection.rs:11:44
|
11 | _ = Router::<()>::new().route("/", get(foo));
| --- ^^^ the trait `Handler<_, _>` is not implemented for fn item `fn(Extractor<()>) -> impl Future<Output = ()> {foo}`
| |
| required by a bound introduced by this call
|
= note: Consider using `#[axum::debug_handler]` to improve the error message
= help: the following other types implement trait `Handler<T, S>`:
<Layered<L, H, T, S> as Handler<T, S>>
<MethodRouter<S> as Handler<(), S>>
note: required by a bound in `axum::routing::get`
--> $WORKSPACE/axum/src/routing/method_routing.rs
|
| top_level_handler_fn!(get, GET);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `axum::routing::get`
= note: this error originates in the macro `top_level_handler_fn` (in Nightly builds, run with -Z macro-backtrace for more info)
--> $WORKSPACE/axum/src/routing/method_routing.rs
|
| top_level_handler_fn!(get, GET);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `axum::routing::get`
= note: this error originates in the macro `top_level_handler_fn` (in Nightly builds, run with -Z macro-backtrace for more info)
@@ -4,18 +4,18 @@ error: cannot use `rejection` without `via`
18 | #[from_request(rejection(MyRejection))]
| ^^^^^^^^^
error[E0277]: the trait bound `fn(MyExtractor) -> impl Future<Output = ()> {handler}: Handler<_, _, _>` is not satisfied
error[E0277]: the trait bound `fn(MyExtractor) -> impl Future<Output = ()> {handler}: Handler<_, _>` is not satisfied
--> tests/from_request/fail/override_rejection_on_enum_without_via.rs:10:50
|
10 | let _: Router = Router::new().route("/", get(handler).post(handler_result));
| --- ^^^^^^^ the trait `Handler<_, _, _>` is not implemented for fn item `fn(MyExtractor) -> impl Future<Output = ()> {handler}`
| --- ^^^^^^^ the trait `Handler<_, _>` is not implemented for fn item `fn(MyExtractor) -> impl Future<Output = ()> {handler}`
| |
| required by a bound introduced by this call
|
= note: Consider using `#[axum::debug_handler]` to improve the error message
= help: the following other types implement trait `Handler<T, S, B>`:
<Layered<L, H, T, S, B, B2> as Handler<T, S, B2>>
<MethodRouter<S, B> as Handler<(), S, B>>
= help: the following other types implement trait `Handler<T, S>`:
<Layered<L, H, T, S> as Handler<T, S>>
<MethodRouter<S> as Handler<(), S>>
note: required by a bound in `axum::routing::get`
--> $WORKSPACE/axum/src/routing/method_routing.rs
|
@@ -23,21 +23,21 @@ note: required by a bound in `axum::routing::get`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `axum::routing::get`
= note: this error originates in the macro `top_level_handler_fn` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `fn(Result<MyExtractor, MyRejection>) -> impl Future<Output = ()> {handler_result}: Handler<_, _, _>` is not satisfied
error[E0277]: the trait bound `fn(Result<MyExtractor, MyRejection>) -> impl Future<Output = ()> {handler_result}: Handler<_, _>` is not satisfied
--> tests/from_request/fail/override_rejection_on_enum_without_via.rs:10:64
|
10 | let _: Router = Router::new().route("/", get(handler).post(handler_result));
| ---- ^^^^^^^^^^^^^^ the trait `Handler<_, _, _>` is not implemented for fn item `fn(Result<MyExtractor, MyRejection>) -> impl Future<Output = ()> {handler_result}`
| ---- ^^^^^^^^^^^^^^ the trait `Handler<_, _>` is not implemented for fn item `fn(Result<MyExtractor, MyRejection>) -> impl Future<Output = ()> {handler_result}`
| |
| required by a bound introduced by this call
|
= note: Consider using `#[axum::debug_handler]` to improve the error message
= help: the following other types implement trait `Handler<T, S, B>`:
<Layered<L, H, T, S, B, B2> as Handler<T, S, B2>>
<MethodRouter<S, B> as Handler<(), S, B>>
note: required by a bound in `MethodRouter::<S, B>::post`
= help: the following other types implement trait `Handler<T, S>`:
<Layered<L, H, T, S> as Handler<T, S>>
<MethodRouter<S> as Handler<(), S>>
note: required by a bound in `MethodRouter::<S>::post`
--> $WORKSPACE/axum/src/routing/method_routing.rs
|
| chained_handler_fn!(post, POST);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `MethodRouter::<S, B>::post`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `MethodRouter::<S>::post`
= note: this error originates in the macro `chained_handler_fn` (in Nightly builds, run with -Z macro-backtrace for more info)
@@ -15,7 +15,7 @@ struct OtherState {}
fn assert_from_request()
where
Extractor: axum::extract::FromRequest<AppState, axum::body::Body, Rejection = axum::response::Response>,
Extractor: axum::extract::FromRequest<AppState, Rejection = axum::response::Response>,
{
}
@@ -1,5 +1,4 @@
use axum::{
body::Body,
extract::{FromRequest, Json},
response::Response,
};
@@ -15,7 +14,7 @@ struct Extractor {
fn assert_from_request()
where
Extractor: FromRequest<(), Body, Rejection = Response>,
Extractor: FromRequest<(), Rejection = Response>,
{
}
@@ -5,7 +5,7 @@ struct Extractor {}
fn assert_from_request()
where
Extractor: axum::extract::FromRequest<(), axum::body::Body, Rejection = std::convert::Infallible>,
Extractor: axum::extract::FromRequest<(), Rejection = std::convert::Infallible>,
{
}
@@ -5,7 +5,7 @@ struct Extractor();
fn assert_from_request()
where
Extractor: axum::extract::FromRequest<(), axum::body::Body, Rejection = std::convert::Infallible>,
Extractor: axum::extract::FromRequest<(), Rejection = std::convert::Infallible>,
{
}
@@ -1,4 +1,4 @@
use axum::{body::Body, routing::get, Extension, Router};
use axum::{routing::get, Extension, Router};
use axum_macros::FromRequest;
#[derive(FromRequest, Clone)]
@@ -8,5 +8,5 @@ enum Extractor {}
async fn foo(_: Extractor) {}
fn main() {
Router::<(), Body>::new().route("/", get(foo));
_ = Router::<()>::new().route("/", get(foo));
}
@@ -1,4 +1,4 @@
use axum::{body::Body, routing::get, Extension, Router};
use axum::{routing::get, Extension, Router};
use axum_macros::FromRequestParts;
#[derive(FromRequestParts, Clone)]
@@ -8,5 +8,5 @@ enum Extractor {}
async fn foo(_: Extractor) {}
fn main() {
Router::<(), Body>::new().route("/", get(foo));
_ = Router::<()>::new().route("/", get(foo));
}
+1 -2
View File
@@ -1,5 +1,4 @@
use axum::{
body::Body,
extract::{FromRequest, TypedHeader, rejection::TypedHeaderRejection},
response::Response,
headers::{self, UserAgent},
@@ -17,7 +16,7 @@ struct Extractor {
fn assert_from_request()
where
Extractor: FromRequest<(), Body, Rejection = Response>,
Extractor: FromRequest<(), Rejection = Response>,
{
}
@@ -1,5 +1,4 @@
use axum::{
body::Body,
response::Response,
extract::{
rejection::TypedHeaderRejection,
@@ -24,7 +23,7 @@ struct Extractor {
fn assert_from_request()
where
Extractor: FromRequest<(), Body, Rejection = Response>,
Extractor: FromRequest<(), Rejection = Response>,
{
}
@@ -4,6 +4,7 @@ use axum::{
http::{StatusCode, Request},
response::{IntoResponse, Response},
routing::get,
body::Body,
Extension, Router,
};
@@ -27,15 +28,14 @@ struct MyExtractor {
struct OtherExtractor;
#[async_trait]
impl<S, B> FromRequest<S, B> for OtherExtractor
impl<S> FromRequest<S> for OtherExtractor
where
B: Send + 'static,
S: Send + Sync,
{
// this rejection doesn't implement `Display` and `Error`
type Rejection = (StatusCode, String);
async fn from_request(_req: Request<B>, _state: &S) -> Result<Self, Self::Rejection> {
async fn from_request(_req: Request<Body>, _state: &S) -> Result<Self, Self::Rejection> {
todo!()
}
}
@@ -20,7 +20,7 @@ impl FromRef<AppState> for Key {
fn assert_from_request()
where
Extractor: axum::extract::FromRequest<AppState, axum::body::Body, Rejection = axum::response::Response>,
Extractor: axum::extract::FromRequest<AppState, Rejection = axum::response::Response>,
{
}
@@ -11,7 +11,7 @@ struct AppState {}
fn assert_from_request()
where
Extractor: axum::extract::FromRequest<AppState, axum::body::Body, Rejection = axum::response::Response>,
Extractor: axum::extract::FromRequest<AppState, Rejection = axum::response::Response>,
{
}
@@ -12,7 +12,7 @@ struct AppState {}
fn assert_from_request()
where
Extractor: axum::extract::FromRequest<AppState, axum::body::Body, Rejection = axum::response::Response>,
Extractor: axum::extract::FromRequest<AppState, Rejection = axum::response::Response>,
{
}
+1 -1
View File
@@ -5,7 +5,7 @@ struct Extractor(axum::http::HeaderMap, String);
fn assert_from_request()
where
Extractor: axum::extract::FromRequest<(), axum::body::Body>,
Extractor: axum::extract::FromRequest<()>,
{
}
@@ -13,7 +13,7 @@ struct Payload {}
fn assert_from_request()
where
Extractor: axum::extract::FromRequest<(), axum::body::Body>,
Extractor: axum::extract::FromRequest<()>,
{
}
@@ -14,7 +14,7 @@ struct Payload {}
fn assert_from_request()
where
Extractor: axum::extract::FromRequest<(), axum::body::Body, Rejection = Response>,
Extractor: axum::extract::FromRequest<(), Rejection = Response>,
{
}
@@ -9,7 +9,7 @@ struct State;
fn assert_from_request()
where
Extractor: axum::extract::FromRequest<(), axum::body::Body>,
Extractor: axum::extract::FromRequest<()>,
{
}
+1 -1
View File
@@ -5,7 +5,7 @@ struct Extractor;
fn assert_from_request()
where
Extractor: axum::extract::FromRequest<(), axum::body::Body, Rejection = std::convert::Infallible>,
Extractor: axum::extract::FromRequest<(), Rejection = std::convert::Infallible>,
{
}