From 33d2aea6504edba70b017f1678f8e1e3ec12e3ba Mon Sep 17 00:00:00 2001 From: stormshield-gt <143998166+stormshield-gt@users.noreply.github.com> Date: Wed, 3 Apr 2024 16:57:30 +0200 Subject: [PATCH] chore: bump reqwest to 0.12 (#17) --- Cargo.toml | 5 ++-- rustify_derive/src/error.rs | 1 + src/client.rs | 3 +++ src/clients/reqwest.rs | 3 +++ src/endpoint.rs | 6 +++++ tests/macro.rs | 1 + tests/macro/empty_attr.stderr | 19 ++++++++++++++++ tests/macro/invalid_data.stderr | 38 +++++++++++++++++++++++++++++++ tests/macro/invalid_method.stderr | 13 +++++++++++ tests/macro/invalid_result.stderr | 13 +++++++++++ tests/macro/invalid_type.stderr | 19 ++++++++++++++++ tests/macro/no_attr.stderr | 15 ++++++++++++ tests/macro/no_path.stderr | 15 ++++++++++++ 13 files changed, 149 insertions(+), 2 deletions(-) create mode 100644 tests/macro/empty_attr.stderr create mode 100644 tests/macro/invalid_data.stderr create mode 100644 tests/macro/invalid_method.stderr create mode 100644 tests/macro/invalid_result.stderr create mode 100644 tests/macro/invalid_type.stderr create mode 100644 tests/macro/no_attr.stderr create mode 100644 tests/macro/no_path.stderr diff --git a/Cargo.toml b/Cargo.toml index 9d3773b..56ba61d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,8 +26,8 @@ members = [ anyhow = "1.0.56" async-trait = "0.1.52" bytes = "1.1.0" -http = "0.2.6" -reqwest = { version = "0.11.10", default-features = false, optional = true } +http = "1" +reqwest = { version = "0.12.2", default-features = false, optional = true } rustify_derive = { version = "0.5.2", path = "rustify_derive" } serde = { version = "1.0.136", features = ["derive"] } serde_json = "1.0.79" @@ -40,6 +40,7 @@ url = "2.2.2" derive_builder = "0.10.2" env_logger = "0.9.0" httpmock = "0.6.6" +rustversion = "1" test-log = { version = "0.2.8", features = ["trace"] } tokio = "1.17.0" tokio-test = "0.4.2" diff --git a/rustify_derive/src/error.rs b/rustify_derive/src/error.rs index 1814329..6a2369f 100644 --- a/rustify_derive/src/error.rs +++ b/rustify_derive/src/error.rs @@ -1,4 +1,5 @@ use proc_macro2::Span; +use quote::quote_spanned; /// The general error object returned by functions in this crate. /// diff --git a/src/client.rs b/src/client.rs index d90973a..d8db7a9 100644 --- a/src/client.rs +++ b/src/client.rs @@ -24,6 +24,9 @@ pub trait Client: Sync + Send { /// This method provides a common interface to /// [Endpoints][crate::endpoint::Endpoint] for execution. + // TODO: remove the allow when the upstream clippy issue is fixed: + // + #[allow(clippy::blocks_in_conditions)] #[instrument(skip(self, req), err)] async fn execute(&self, req: Request>) -> Result>, ClientError> { debug!( diff --git a/src/clients/reqwest.rs b/src/clients/reqwest.rs index 9230959..ea7de16 100644 --- a/src/clients/reqwest.rs +++ b/src/clients/reqwest.rs @@ -65,6 +65,9 @@ impl RustifyClient for Client { self.base.as_str() } + // TODO: remove the allow when the upstream clippy issue is fixed: + // + #[allow(clippy::blocks_in_conditions)] #[instrument(skip(self, req), err)] async fn send(&self, req: Request>) -> Result>, ClientError> { let request = reqwest::Request::try_from(req) diff --git a/src/endpoint.rs b/src/endpoint.rs index 6ba1fbe..7b5bbe1 100644 --- a/src/endpoint.rs +++ b/src/endpoint.rs @@ -87,6 +87,9 @@ impl Endpoint for MutatedEndpoint<'_, E, M> { Ok(req) } + // TODO: remove the allow when the upstream clippy issue is fixed: + // + #[allow(clippy::blocks_in_conditions)] #[instrument(skip(self, client), err)] async fn exec( &self, @@ -221,6 +224,9 @@ pub trait Endpoint: Send + Sync + Sized { } /// Executes the Endpoint using the given [Client]. + // TODO: remove the allow when the upstream clippy issue is fixed: + // + #[allow(clippy::blocks_in_conditions)] #[instrument(skip(self, client), err)] async fn exec( &self, diff --git a/tests/macro.rs b/tests/macro.rs index f3710d5..2aebda6 100644 --- a/tests/macro.rs +++ b/tests/macro.rs @@ -1,3 +1,4 @@ +#[rustversion::attr(not(nightly), ignore)] #[test] fn test_macro() { let t = trybuild::TestCases::new(); diff --git a/tests/macro/empty_attr.stderr b/tests/macro/empty_attr.stderr new file mode 100644 index 0000000..3457d18 --- /dev/null +++ b/tests/macro/empty_attr.stderr @@ -0,0 +1,19 @@ +error: Cannot parse attribute as list + --> tests/macro/empty_attr.rs:6:3 + | +6 | #[endpoint] + | ^^^^^^^^ + +error: Attribute cannot be empty + --> tests/macro/empty_attr.rs:10:3 + | +10 | #[endpoint()] + | ^^^^^^^^^^ + +warning: unused import: `rustify::endpoint::Endpoint` + --> tests/macro/empty_attr.rs:1:5 + | +1 | use rustify::endpoint::Endpoint; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `#[warn(unused_imports)]` on by default diff --git a/tests/macro/invalid_data.stderr b/tests/macro/invalid_data.stderr new file mode 100644 index 0000000..5f721ad --- /dev/null +++ b/tests/macro/invalid_data.stderr @@ -0,0 +1,38 @@ +error: May only mark one field as raw + --> tests/macro/invalid_data.rs:19:5 + | +19 | / #[endpoint(raw)] +20 | | pub data_two: Vec, + | |_________________________^ + +warning: unused import: `rustify::endpoint::Endpoint` + --> tests/macro/invalid_data.rs:1:5 + | +1 | use rustify::endpoint::Endpoint; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `#[warn(unused_imports)]` on by default + +error[E0308]: mismatched types + --> tests/macro/invalid_data.rs:5:17 + | +5 | #[derive(Debug, Endpoint, Serialize)] + | ^^^^^^^^ + | | + | expected `Vec`, found `String` + | arguments to this enum variant are incorrect + | + = note: expected struct `Vec` + found struct `std::string::String` +help: the type constructed contains `std::string::String` due to the type of the argument passed + --> tests/macro/invalid_data.rs:5:17 + | +5 | #[derive(Debug, Endpoint, Serialize)] + | ^^^^^^^^ this argument influences the type of `Some` +note: tuple variant defined here + --> $RUST/core/src/option.rs + = note: this error originates in the derive macro `Endpoint` (in Nightly builds, run with -Z macro-backtrace for more info) +help: call `Into::into` on this expression to convert `std::string::String` into `Vec` + | +5 | #[derive(Debug, Endpoint.into(), Serialize)] + | +++++++ diff --git a/tests/macro/invalid_method.stderr b/tests/macro/invalid_method.stderr new file mode 100644 index 0000000..c04ca07 --- /dev/null +++ b/tests/macro/invalid_method.stderr @@ -0,0 +1,13 @@ +warning: unused import: `rustify::endpoint::Endpoint` + --> tests/macro/invalid_method.rs:1:5 + | +1 | use rustify::endpoint::Endpoint; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `#[warn(unused_imports)]` on by default + +error[E0599]: no variant or associated item named `TEST` found for enum `RequestMethod` in the current scope + --> tests/macro/invalid_method.rs:6:41 + | +6 | #[endpoint(path = "test/path", method = "TEST")] + | ^^^^^^ variant or associated item not found in `RequestMethod` diff --git a/tests/macro/invalid_result.stderr b/tests/macro/invalid_result.stderr new file mode 100644 index 0000000..08f3adb --- /dev/null +++ b/tests/macro/invalid_result.stderr @@ -0,0 +1,13 @@ +error: Unknown parameter + --> tests/macro/invalid_result.rs:6:32 + | +6 | #[endpoint(path = "test/path", result = "DoesNotExist")] + | ^^^^^^ + +warning: unused import: `rustify::endpoint::Endpoint` + --> tests/macro/invalid_result.rs:1:5 + | +1 | use rustify::endpoint::Endpoint; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `#[warn(unused_imports)]` on by default diff --git a/tests/macro/invalid_type.stderr b/tests/macro/invalid_type.stderr new file mode 100644 index 0000000..b041ce7 --- /dev/null +++ b/tests/macro/invalid_type.stderr @@ -0,0 +1,19 @@ +warning: unused import: `rustify::endpoint::Endpoint` + --> tests/macro/invalid_type.rs:1:5 + | +1 | use rustify::endpoint::Endpoint; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `#[warn(unused_imports)]` on by default + +error[E0599]: no variant or associated item named `BAD` found for enum `RequestType` in the current scope + --> tests/macro/invalid_type.rs:6:47 + | +6 | #[endpoint(path = "test/path", request_type = "BAD", response_type = "BAD")] + | ^^^^^ variant or associated item not found in `RequestType` + +error[E0599]: no variant or associated item named `BAD` found for enum `ResponseType` in the current scope + --> tests/macro/invalid_type.rs:6:70 + | +6 | #[endpoint(path = "test/path", request_type = "BAD", response_type = "BAD")] + | ^^^^^ variant or associated item not found in `ResponseType` diff --git a/tests/macro/no_attr.stderr b/tests/macro/no_attr.stderr new file mode 100644 index 0000000..07d7749 --- /dev/null +++ b/tests/macro/no_attr.stderr @@ -0,0 +1,15 @@ +error: Deriving `Endpoint` requires attaching an `endpoint` attribute + --> tests/macro/no_attr.rs:5:17 + | +5 | #[derive(Debug, Endpoint, Serialize)] + | ^^^^^^^^ + | + = note: this error originates in the derive macro `Endpoint` (in Nightly builds, run with -Z macro-backtrace for more info) + +warning: unused import: `rustify::endpoint::Endpoint` + --> tests/macro/no_attr.rs:1:5 + | +1 | use rustify::endpoint::Endpoint; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `#[warn(unused_imports)]` on by default diff --git a/tests/macro/no_path.stderr b/tests/macro/no_path.stderr new file mode 100644 index 0000000..a3ab12a --- /dev/null +++ b/tests/macro/no_path.stderr @@ -0,0 +1,15 @@ +error: Missing required parameter: path + --> tests/macro/no_path.rs:5:17 + | +5 | #[derive(Debug, Endpoint, Serialize)] + | ^^^^^^^^ + | + = note: this error originates in the derive macro `Endpoint` (in Nightly builds, run with -Z macro-backtrace for more info) + +warning: unused import: `rustify::endpoint::Endpoint` + --> tests/macro/no_path.rs:1:5 + | +1 | use rustify::endpoint::Endpoint; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `#[warn(unused_imports)]` on by default