Use the diagnostic namespace (#2246)

This commit is contained in:
Georg Semmler 2023-09-29 07:25:26 +00:00 committed by GitHub
parent 930e2ab7c1
commit 2f6200dfbd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 126 additions and 109 deletions

View file

@ -45,7 +45,7 @@ mod private {
#[async_trait]
#[cfg_attr(
nightly_error_messages,
rustc_on_unimplemented(
diagnostic::on_unimplemented(
note = "Function argument is not a valid axum extractor. \nSee `https://docs.rs/axum/latest/axum/extract/index.html` for details",
)
)]
@ -72,7 +72,7 @@ pub trait FromRequestParts<S>: Sized {
#[async_trait]
#[cfg_attr(
nightly_error_messages,
rustc_on_unimplemented(
diagnostic::on_unimplemented(
note = "Function argument is not a valid axum extractor. \nSee `https://docs.rs/axum/latest/axum/extract/index.html` for details",
)
)]

View file

@ -1,4 +1,4 @@
#![cfg_attr(nightly_error_messages, allow(internal_features), feature(rustc_attrs))]
#![cfg_attr(nightly_error_messages, feature(diagnostic_namespace))]
//! Core types and traits for [`axum`].
//!
//! Libraries authors that want to provide [`FromRequest`] or [`IntoResponse`] implementations
@ -44,7 +44,7 @@
missing_debug_implementations,
missing_docs
)]
#![deny(unreachable_pub, private_in_public)]
#![deny(unreachable_pub)]
#![allow(elided_lifetimes_in_paths, clippy::type_complexity)]
#![forbid(unsafe_code)]
#![cfg_attr(test, allow(clippy::float_cmp))]

View file

@ -60,7 +60,7 @@
missing_debug_implementations,
missing_docs
)]
#![deny(unreachable_pub, private_in_public)]
#![deny(unreachable_pub)]
#![allow(elided_lifetimes_in_paths, clippy::type_complexity)]
#![forbid(unsafe_code)]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

View file

@ -1 +1 @@
nightly-2023-04-06
nightly-2023-09-23

View file

@ -37,7 +37,7 @@
missing_debug_implementations,
missing_docs
)]
#![deny(unreachable_pub, private_in_public)]
#![deny(unreachable_pub)]
#![allow(elided_lifetimes_in_paths, clippy::type_complexity)]
#![forbid(unsafe_code)]
#![cfg_attr(docsrs, feature(doc_cfg))]

View file

@ -1,6 +1,7 @@
#![feature(diagnostic_namespace)]
use axum_macros::debug_handler;
#[debug_handler]
async fn handler(foo: bool) {}
async fn handler(_foo: bool) {}
fn main() {}

View file

@ -1,24 +1,24 @@
error[E0277]: the trait bound `bool: FromRequestParts<()>` is not satisfied
--> tests/debug_handler/fail/argument_not_extractor.rs:4:23
--> tests/debug_handler/fail/argument_not_extractor.rs:5:24
|
4 | async fn handler(foo: bool) {}
5 | async fn handler(_foo: bool) {}
| ^^^^ the trait `FromRequestParts<()>` is not implemented for `bool`
|
= note: Function argument is not a valid axum extractor.
See `https://docs.rs/axum/latest/axum/extract/index.html` for details
= help: the following other types implement trait `FromRequestParts<S>`:
<() as FromRequestParts<S>>
<(T1, T2) as FromRequestParts<S>>
<(T1, T2, T3) as FromRequestParts<S>>
<(T1, T2, T3, T4) as FromRequestParts<S>>
<(T1, T2, T3, T4, T5) as FromRequestParts<S>>
<(T1, T2, T3, T4, T5, T6) as FromRequestParts<S>>
<(T1, T2, T3, T4, T5, T6, T7) as FromRequestParts<S>>
<(T1, T2, T3, T4, T5, T6, T7, T8) as FromRequestParts<S>>
<HeaderMap as FromRequestParts<S>>
<Extension<T> as FromRequestParts<S>>
<Method as FromRequestParts<S>>
<Uri as FromRequestParts<S>>
<Version as FromRequestParts<S>>
<ConnectInfo<T> as FromRequestParts<S>>
<axum::extract::Path<T> as FromRequestParts<S>>
<RawPathParams as FromRequestParts<S>>
and $N others
= note: required for `bool` to implement `FromRequest<(), axum_core::extract::private::ViaParts>`
note: required by a bound in `__axum_macros_check_handler_0_from_request_check`
--> tests/debug_handler/fail/argument_not_extractor.rs:4:23
--> tests/debug_handler/fail/argument_not_extractor.rs:5:24
|
4 | async fn handler(foo: bool) {}
5 | async fn handler(_foo: bool) {}
| ^^^^ required by this bound in `__axum_macros_check_handler_0_from_request_check`

View file

@ -1,6 +1,6 @@
use axum_macros::debug_handler;
#[debug_handler]
async fn handler<T>(extract: T) {}
async fn handler<T>(_extract: T) {}
fn main() {}

View file

@ -1,5 +1,5 @@
error: `#[axum_macros::debug_handler]` doesn't support generic functions
--> tests/debug_handler/fail/generics.rs:4:17
|
4 | async fn handler<T>(extract: T) {}
4 | async fn handler<T>(_extract: T) {}
| ^^^

View file

@ -5,14 +5,14 @@ error[E0277]: the trait bound `for<'de> Struct: serde::de::Deserialize<'de>` is
| ^^^^^^^^^^^^ the trait `for<'de> serde::de::Deserialize<'de>` is not implemented for `Struct`
|
= help: the following other types implement trait `serde::de::Deserialize<'de>`:
&'a [u8]
&'a serde_json::raw::RawValue
&'a std::path::Path
&'a str
()
(T0, T1)
(T0, T1, T2)
(T0, T1, T2, T3)
bool
char
isize
i8
i16
i32
i64
i128
and $N others
= note: required for `Struct` to implement `serde::de::DeserializeOwned`
= note: required for `Json<Struct>` to implement `FromRequest<()>`

View file

@ -2,7 +2,7 @@ use axum_macros::debug_handler;
#[debug_handler]
async fn handler() {
let rc = std::rc::Rc::new(());
let _rc = std::rc::Rc::new(());
async {}.await;
}

View file

@ -6,14 +6,14 @@ error: future cannot be sent between threads safely
|
= help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<()>`
note: future is not `Send` as this value is used across an await
--> tests/debug_handler/fail/not_send.rs:6:13
--> tests/debug_handler/fail/not_send.rs:6:14
|
5 | let rc = std::rc::Rc::new(());
| -- has type `Rc<()>` which is not `Send`
5 | let _rc = std::rc::Rc::new(());
| --- has type `Rc<()>` which is not `Send`
6 | async {}.await;
| ^^^^^^ await occurs here, with `rc` maybe used later
| ^^^^^ await occurs here, with `_rc` maybe used later
7 | }
| - `rc` is later dropped here
| - `_rc` is later dropped here
note: required by a bound in `check`
--> tests/debug_handler/fail/not_send.rs:3:1
|

View file

@ -3,23 +3,23 @@ use axum::http::Uri;
#[debug_handler]
async fn handler(
e1: Uri,
e2: Uri,
e3: Uri,
e4: Uri,
e5: Uri,
e6: Uri,
e7: Uri,
e8: Uri,
e9: Uri,
e10: Uri,
e11: Uri,
e12: Uri,
e13: Uri,
e14: Uri,
e15: Uri,
e16: Uri,
e17: Uri,
_e1: Uri,
_e2: Uri,
_e3: Uri,
_e4: Uri,
_e5: Uri,
_e6: Uri,
_e7: Uri,
_e8: Uri,
_e9: Uri,
_e10: Uri,
_e11: Uri,
_e12: Uri,
_e13: Uri,
_e14: Uri,
_e15: Uri,
_e16: Uri,
_e17: Uri,
) {}
fn main() {}

View file

@ -1,11 +1,11 @@
error: Handlers cannot take more than 16 arguments. Use `(a, b): (ExtractorA, ExtractorA)` to further nest extractors
--> tests/debug_handler/fail/too_many_extractors.rs:6:5
|
6 | / e1: Uri,
7 | | e2: Uri,
8 | | e3: Uri,
9 | | e4: Uri,
6 | / _e1: Uri,
7 | | _e2: Uri,
8 | | _e3: Uri,
9 | | _e4: Uri,
... |
21 | | e16: Uri,
22 | | e17: Uri,
| |_____________^
21 | | _e16: Uri,
22 | | _e17: Uri,
| |______________^

View file

@ -5,14 +5,14 @@ error[E0277]: the trait bound `bool: IntoResponse` is not satisfied
| ^^^^ the trait `IntoResponse` is not implemented for `bool`
|
= help: the following other types implement trait `IntoResponse`:
&'static [u8; N]
&'static [u8]
&'static str
()
(R,)
(Response<()>, R)
(Response<()>, T1, R)
(Response<()>, T1, T2, R)
Box<str>
Box<[u8]>
axum::body::Bytes
Body
axum::extract::rejection::FailedToBufferBody
axum::extract::rejection::LengthLimitError
axum::extract::rejection::UnknownBodyError
axum::extract::rejection::InvalidUtf8
and $N others
note: required by a bound in `__axum_macros_check_handler_into_response::{closure#0}::check`
--> tests/debug_handler/fail/wrong_return_type.rs:4:23

View file

@ -1,3 +1,4 @@
#![feature(diagnostic_namespace)]
use axum::{routing::get, Router};
use axum_macros::FromRequest;

View file

@ -1,13 +1,13 @@
error: #[derive(FromRequest)] only supports generics when used with #[from_request(via)]
--> tests/from_request/fail/generic_without_via.rs:5:18
--> tests/from_request/fail/generic_without_via.rs:6:18
|
5 | struct Extractor<T>(T);
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.rs:10:44
--> tests/from_request/fail/generic_without_via.rs:11:44
|
10 | _ = Router::<()>::new().route("/", get(foo));
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
@ -20,5 +20,8 @@ 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 `get`
| ^^^^^^^^^^^^^^^^^^^^^^---^^^^^^
| | |
| | required by a bound in this function
| required by this bound in `get`
= note: this error originates in the macro `top_level_handler_fn` (in Nightly builds, run with -Z macro-backtrace for more info)

View file

@ -1,3 +1,4 @@
#![feature(diagnostic_namespace)]
use axum::{routing::get, Router};
use axum_macros::FromRequest;

View file

@ -1,13 +1,13 @@
error: #[derive(FromRequest)] only supports generics when used with #[from_request(via)]
--> tests/from_request/fail/generic_without_via_rejection.rs:6:18
--> tests/from_request/fail/generic_without_via_rejection.rs:7:18
|
6 | struct Extractor<T>(T);
7 | 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:44
--> tests/from_request/fail/generic_without_via_rejection.rs:12:44
|
11 | _ = Router::<()>::new().route("/", get(foo));
12 | _ = 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
@ -20,5 +20,8 @@ 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 `get`
| ^^^^^^^^^^^^^^^^^^^^^^---^^^^^^
| | |
| | required by a bound in this function
| required by this bound in `get`
= note: this error originates in the macro `top_level_handler_fn` (in Nightly builds, run with -Z macro-backtrace for more info)

View file

@ -1,3 +1,4 @@
#![feature(diagnostic_namespace)]
use axum::{
extract::rejection::ExtensionRejection,
response::{IntoResponse, Response},

View file

@ -1,13 +1,13 @@
error: cannot use `rejection` without `via`
--> tests/from_request/fail/override_rejection_on_enum_without_via.rs:18:16
--> tests/from_request/fail/override_rejection_on_enum_without_via.rs:19:16
|
18 | #[from_request(rejection(MyRejection))]
19 | #[from_request(rejection(MyRejection))]
| ^^^^^^^^^
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
--> tests/from_request/fail/override_rejection_on_enum_without_via.rs:11:50
|
10 | let _: Router = Router::new().route("/", get(handler).post(handler_result));
11 | 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}`
| |
| required by a bound introduced by this call
@ -20,13 +20,16 @@ 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 `get`
| ^^^^^^^^^^^^^^^^^^^^^^---^^^^^^
| | |
| | required by a bound in this function
| required by this bound in `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
--> tests/from_request/fail/override_rejection_on_enum_without_via.rs:10:64
--> tests/from_request/fail/override_rejection_on_enum_without_via.rs:11:64
|
10 | let _: Router = Router::new().route("/", get(handler).post(handler_result));
11 | 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}`
| |
| required by a bound introduced by this call
@ -39,5 +42,8 @@ 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>::post`
| ^^^^^^^^^^^^^^^^^^^^----^^^^^^^
| | |
| | required by a bound in this associated function
| 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)

View file

@ -1,3 +1,4 @@
#![feature(diagnostic_namespace)]
use axum::{extract::FromRequestParts, response::Response};
#[derive(FromRequestParts)]

View file

@ -1,18 +1,18 @@
error[E0277]: the trait bound `String: FromRequestParts<S>` is not satisfied
--> tests/from_request/fail/parts_extracting_body.rs:5:11
--> tests/from_request/fail/parts_extracting_body.rs:6:11
|
5 | body: String,
6 | body: String,
| ^^^^^^ the trait `FromRequestParts<S>` is not implemented for `String`
|
= note: Function argument is not a valid axum extractor.
See `https://docs.rs/axum/latest/axum/extract/index.html` for details
= help: the following other types implement trait `FromRequestParts<S>`:
<() as FromRequestParts<S>>
<(T1, T2) as FromRequestParts<S>>
<(T1, T2, T3) as FromRequestParts<S>>
<(T1, T2, T3, T4) as FromRequestParts<S>>
<(T1, T2, T3, T4, T5) as FromRequestParts<S>>
<(T1, T2, T3, T4, T5, T6) as FromRequestParts<S>>
<(T1, T2, T3, T4, T5, T6, T7) as FromRequestParts<S>>
<(T1, T2, T3, T4, T5, T6, T7, T8) as FromRequestParts<S>>
<Extractor as FromRequestParts<S>>
<HeaderMap as FromRequestParts<S>>
<Extension<T> as FromRequestParts<S>>
<Method as FromRequestParts<S>>
<Uri as FromRequestParts<S>>
<Version as FromRequestParts<S>>
<ConnectInfo<T> as FromRequestParts<S>>
<axum::extract::Path<T> as FromRequestParts<S>>
and $N others

View file

@ -5,14 +5,14 @@ error[E0277]: the trait bound `for<'de> MyPath: serde::de::Deserialize<'de>` is
| ^^^^^^^^^ the trait `for<'de> serde::de::Deserialize<'de>` is not implemented for `MyPath`
|
= help: the following other types implement trait `serde::de::Deserialize<'de>`:
&'a [u8]
&'a serde_json::raw::RawValue
&'a std::path::Path
&'a str
()
(T0, T1)
(T0, T1, T2)
(T0, T1, T2, T3)
bool
char
isize
i8
i16
i32
i64
i128
and $N others
= note: required for `MyPath` to implement `serde::de::DeserializeOwned`
= note: required for `axum::extract::Path<MyPath>` to implement `FromRequestParts<S>`

View file

@ -127,7 +127,7 @@ pub use self::service::HandlerService;
/// ```
#[cfg_attr(
nightly_error_messages,
rustc_on_unimplemented(
diagnostic::on_unimplemented(
note = "Consider using `#[axum::debug_handler]` to improve the error message"
)
)]

View file

@ -1,4 +1,4 @@
#![cfg_attr(nightly_error_messages, allow(internal_features), feature(rustc_attrs))]
#![cfg_attr(nightly_error_messages, feature(diagnostic_namespace))]
//! axum is a web application framework that focuses on ergonomics and modularity.
//!
//! # Table of contents
@ -416,7 +416,7 @@
missing_debug_implementations,
missing_docs
)]
#![deny(unreachable_pub, private_in_public)]
#![deny(unreachable_pub)]
#![allow(elided_lifetimes_in_paths, clippy::type_complexity)]
// can't be `forbid` since we've vendored code from hyper-util that contains `unsafe`
// when hyper-util is on crates.io we can stop vendoring it and go back to `forbid`