From cfb48a62cf2379871efe59d8b1a2b5c3dae58916 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Sun, 31 Mar 2024 20:04:39 +0200 Subject: [PATCH] Enable diagnostic attributes for Rust 1.78+ --- axum-core/Cargo.toml | 4 +--- axum-core/build.rs | 7 ------- axum-core/src/extract/mod.rs | 8 ++++---- axum/Cargo.toml | 5 +---- axum/build.rs | 7 ------- axum/src/handler/mod.rs | 4 ++-- 6 files changed, 8 insertions(+), 27 deletions(-) delete mode 100644 axum-core/build.rs delete mode 100644 axum/build.rs diff --git a/axum-core/Cargo.toml b/axum-core/Cargo.toml index bc8a63d452..f9e7869283 100644 --- a/axum-core/Cargo.toml +++ b/axum-core/Cargo.toml @@ -26,6 +26,7 @@ http-body = "1.0.0" http-body-util = "0.1.0" mime = "0.3.16" pin-project-lite = "0.2.7" +rustversion = "1.0.9" sync_wrapper = "1.0.0" tower-layer = "0.3" tower-service = "0.3" @@ -34,9 +35,6 @@ tower-service = "0.3" tower-http = { version = "0.5.0", optional = true, features = ["limit"] } tracing = { version = "0.1.37", default-features = false, optional = true } -[build-dependencies] -rustversion = "1.0.9" - [dev-dependencies] axum = { path = "../axum", version = "0.7.2" } axum-extra = { path = "../axum-extra", features = ["typed-header"] } diff --git a/axum-core/build.rs b/axum-core/build.rs deleted file mode 100644 index b52885c626..0000000000 --- a/axum-core/build.rs +++ /dev/null @@ -1,7 +0,0 @@ -#[rustversion::nightly] -fn main() { - println!("cargo:rustc-cfg=nightly_error_messages"); -} - -#[rustversion::not(nightly)] -fn main() {} diff --git a/axum-core/src/extract/mod.rs b/axum-core/src/extract/mod.rs index c8e2d2196f..f59c1eadde 100644 --- a/axum-core/src/extract/mod.rs +++ b/axum-core/src/extract/mod.rs @@ -43,8 +43,8 @@ mod private { /// /// [`axum::extract`]: https://docs.rs/axum/0.7/axum/extract/index.html #[async_trait] -#[cfg_attr( - nightly_error_messages, +#[rustversion::attr( + since(1.78), diagnostic::on_unimplemented( note = "Function argument is not a valid axum extractor. \nSee `https://docs.rs/axum/0.7/axum/extract/index.html` for details", ) @@ -70,8 +70,8 @@ pub trait FromRequestParts: Sized { /// /// [`axum::extract`]: https://docs.rs/axum/0.7/axum/extract/index.html #[async_trait] -#[cfg_attr( - nightly_error_messages, +#[rustversion::attr( + since(1.78), diagnostic::on_unimplemented( note = "Function argument is not a valid axum extractor. \nSee `https://docs.rs/axum/0.7/axum/extract/index.html` for details", ) diff --git a/axum/Cargo.toml b/axum/Cargo.toml index ab9ba0e4eb..dd2a59da48 100644 --- a/axum/Cargo.toml +++ b/axum/Cargo.toml @@ -54,6 +54,7 @@ memchr = "2.4.1" mime = "0.3.16" percent-encoding = "2.1" pin-project-lite = "0.2.7" +rustversion = "1.0.9" serde = "1.0" sync_wrapper = "1.0.0" tower = { version = "0.4.13", default-features = false, features = ["util"] } @@ -109,16 +110,12 @@ features = [ "validate-request", ] -[build-dependencies] -rustversion = "1.0.9" - [dev-dependencies] anyhow = "1.0" axum-macros = { path = "../axum-macros", version = "0.4.1", features = ["__private"] } quickcheck = "1.0" quickcheck_macros = "1.0" reqwest = { version = "0.12", default-features = false, features = ["json", "stream", "multipart"] } -rustversion = "1.0.9" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" time = { version = "0.3", features = ["serde-human-readable"] } diff --git a/axum/build.rs b/axum/build.rs deleted file mode 100644 index b52885c626..0000000000 --- a/axum/build.rs +++ /dev/null @@ -1,7 +0,0 @@ -#[rustversion::nightly] -fn main() { - println!("cargo:rustc-cfg=nightly_error_messages"); -} - -#[rustversion::not(nightly)] -fn main() {} diff --git a/axum/src/handler/mod.rs b/axum/src/handler/mod.rs index 579fdbbad4..982776145c 100644 --- a/axum/src/handler/mod.rs +++ b/axum/src/handler/mod.rs @@ -125,8 +125,8 @@ pub use self::service::HandlerService; /// ))); /// # let _: Router = app; /// ``` -#[cfg_attr( - nightly_error_messages, +#[rustversion::attr( + since(1.78), diagnostic::on_unimplemented( note = "Consider using `#[axum::debug_handler]` to improve the error message" )