From 431617fdbb305e8f6a2df6ff33d8019ad85e8523 Mon Sep 17 00:00:00 2001 From: Oguz Kocer Date: Wed, 27 Aug 2025 23:06:54 -0400 Subject: [PATCH 1/3] Update Rust to `1.89.0` --- Makefile | 2 +- wp_rs_web/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 884c754c3..729deb4fa 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ docker_container_repo_dir=/app # Common docker options -rust_docker_container := public.ecr.aws/docker/library/rust:1.88.0 +rust_docker_container := public.ecr.aws/docker/library/rust:1.89.0 docker_opts_shared := --rm -v "$(PWD)":$(docker_container_repo_dir) -w $(docker_container_repo_dir) rust_docker_run := docker run -v $(PWD):/$(docker_container_repo_dir) -w $(docker_container_repo_dir) -it -e TEST_ALL_PLUGINS -e CARGO_HOME=/app/.cargo $(rust_docker_container) diff --git a/wp_rs_web/Dockerfile b/wp_rs_web/Dockerfile index 40dea5c76..b07d60a1c 100644 --- a/wp_rs_web/Dockerfile +++ b/wp_rs_web/Dockerfile @@ -1,4 +1,4 @@ -FROM rust:1.88.0 AS builder +FROM rust:1.89.0 AS builder WORKDIR /app From 9b29e9962f3c3959121b465f93092cbb7d0dfed5 Mon Sep 17 00:00:00 2001 From: Oguz Kocer Date: Wed, 27 Aug 2025 23:09:32 -0400 Subject: [PATCH 2/3] Clippy fixes for `1.89.0` --- wp_api/src/api_error.rs | 10 +++++----- wp_api/src/jetpack/connection.rs | 4 +--- wp_api/src/lib.rs | 2 +- wp_api/src/login.rs | 5 ++--- wp_api/src/login/url_discovery.rs | 10 +++++----- wp_api/src/parsed_url.rs | 7 +++---- wp_api/src/request.rs | 4 ++-- wp_api/src/uniffi_serde.rs | 2 +- wp_api/src/uuid.rs | 2 +- wp_api/src/wordpress_org/client.rs | 2 +- wp_derive/src/wp_deserialize.rs | 9 +++------ wp_derive_request_builder/src/variant_attr.rs | 5 ++--- wp_serde_helper/src/wp_serde_date.rs | 5 ++--- 13 files changed, 29 insertions(+), 38 deletions(-) diff --git a/wp_api/src/api_error.rs b/wp_api/src/api_error.rs index 309baefbc..51758fedf 100644 --- a/wp_api/src/api_error.rs +++ b/wp_api/src/api_error.rs @@ -81,7 +81,7 @@ where } impl WpSupportsLocalization for WpApiError { - fn message_bundle(&self) -> MessageBundle { + fn message_bundle(&self) -> MessageBundle<'_> { match self { WpApiError::InvalidHttpStatusCode { status_code } => { WpMessages::invalid_http_status_code(status_code) @@ -510,7 +510,7 @@ pub enum RequestExecutionError { } impl WpSupportsLocalization for RequestExecutionError { - fn message_bundle(&self) -> MessageBundle { + fn message_bundle(&self) -> MessageBundle<'_> { match self { RequestExecutionError::RequestExecutionFailed { reason, .. } => reason.message_bundle(), } @@ -527,7 +527,7 @@ pub enum InvalidSslErrorReason { } impl InvalidSslErrorReason { - fn message_bundle(&self) -> MessageBundle { + fn message_bundle(&self) -> MessageBundle<'_> { match self { Self::CertificateNotValidForName { .. } => { WpMessages::invalid_ssl_error_certificate_not_valid_for_name() @@ -626,7 +626,7 @@ impl RequestExecutionErrorReason { } impl WpSupportsLocalization for RequestExecutionErrorReason { - fn message_bundle(&self) -> MessageBundle { + fn message_bundle(&self) -> MessageBundle<'_> { match self { RequestExecutionErrorReason::InvalidSslError { reason } => reason.message_bundle(), RequestExecutionErrorReason::NonExistentSiteError { .. } => { @@ -675,7 +675,7 @@ pub enum MediaUploadRequestExecutionError { } impl WpSupportsLocalization for MediaUploadRequestExecutionError { - fn message_bundle(&self) -> MessageBundle { + fn message_bundle(&self) -> MessageBundle<'_> { match self { MediaUploadRequestExecutionError::RequestExecutionFailed { reason, .. } => { reason.message_bundle() diff --git a/wp_api/src/jetpack/connection.rs b/wp_api/src/jetpack/connection.rs index 24c9ddf71..73b421747 100644 --- a/wp_api/src/jetpack/connection.rs +++ b/wp_api/src/jetpack/connection.rs @@ -204,11 +204,9 @@ impl JetpackConnectionClient { error_code: WpErrorCode::CustomError(code), .. }) = &result - { - if code == "success" || code == "already_connected" { + && (code == "success" || code == "already_connected") { return Ok(blog_id); } - } let result = result .map_err(JetpackConnectionClientError::Unhandled)? diff --git a/wp_api/src/lib.rs b/wp_api/src/lib.rs index 2a9e6f8cc..182842af1 100644 --- a/wp_api/src/lib.rs +++ b/wp_api/src/lib.rs @@ -149,7 +149,7 @@ pub enum WpApiNewtypeParsingError { } impl WpSupportsLocalization for WpApiNewtypeParsingError { - fn message_bundle(&self) -> MessageBundle { + fn message_bundle(&self) -> MessageBundle<'_> { match self { WpApiNewtypeParsingError::BooleanTrueIsReturnedWhenStringIsExpected => { WpMessages::boolean_true_is_returned_when_string_is_expected() diff --git a/wp_api/src/login.rs b/wp_api/src/login.rs index 420056a7b..a708dd18d 100644 --- a/wp_api/src/login.rs +++ b/wp_api/src/login.rs @@ -36,11 +36,10 @@ pub fn extract_login_details_from_parsed_url( .query_pairs() .find_map(|(k, v)| (k == key).then_some(v.to_string())) }; - if let Some(is_success) = f("success") { - if is_success == "false" { + if let Some(is_success) = f("success") + && is_success == "false" { return Err(OAuthResponseUrlError::UnsuccessfulLogin); } - } let site_url = f("site_url").ok_or(OAuthResponseUrlError::MissingSiteUrl)?; let user_login = f("user_login").ok_or(OAuthResponseUrlError::MissingUsername)?; let password = f("password").ok_or(OAuthResponseUrlError::MissingPassword)?; diff --git a/wp_api/src/login/url_discovery.rs b/wp_api/src/login/url_discovery.rs index f73884e5d..bce0437e7 100644 --- a/wp_api/src/login/url_discovery.rs +++ b/wp_api/src/login/url_discovery.rs @@ -413,7 +413,7 @@ impl AutoDiscoveryAttemptFailure { } impl WpSupportsLocalization for AutoDiscoveryAttemptFailure { - fn message_bundle(&self) -> MessageBundle { + fn message_bundle(&self) -> MessageBundle<'_> { match self { Self::ParseSiteUrl { error } => error.message_bundle(), Self::FindApiRoot { @@ -439,7 +439,7 @@ pub enum FindApiRootFailure { } impl FindApiRootFailure { - fn message_bundle(&self) -> MessageBundle { + fn message_bundle(&self) -> MessageBundle<'_> { match self { Self::FetchHomepage { error } => error.message_bundle(), Self::ProbablyNotAWordPressSite => WpMessages::probably_not_wordpress_site(), @@ -688,7 +688,7 @@ pub enum FetchApiDetailsError { } impl WpSupportsLocalization for FetchApiDetailsError { - fn message_bundle(&self) -> MessageBundle { + fn message_bundle(&self) -> MessageBundle<'_> { match self { FetchApiDetailsError::RequestExecutionFailed { reason, .. } => reason.message_bundle(), FetchApiDetailsError::ApiDetailsCouldntBeParsed { reason, .. } => { @@ -715,7 +715,7 @@ pub enum XmlrpcDisabledReason { } impl WpSupportsLocalization for XmlrpcDiscoveryError { - fn message_bundle(&self) -> MessageBundle { + fn message_bundle(&self) -> MessageBundle<'_> { match self { XmlrpcDiscoveryError::FetchHomepage { error } => error.message_bundle(), XmlrpcDiscoveryError::EndpointNotFound => WpMessages::xmlrpc_endpoint_not_found(), @@ -789,7 +789,7 @@ impl ParseApiRootFailureReason { } } - fn message_bundle(&self) -> MessageBundle { + fn message_bundle(&self) -> MessageBundle<'_> { match self { Self::ServerFatalError => { WpMessages::parse_api_root_failure_reason_server_fatal_error() diff --git a/wp_api/src/parsed_url.rs b/wp_api/src/parsed_url.rs index 174038d12..86dfde2e5 100644 --- a/wp_api/src/parsed_url.rs +++ b/wp_api/src/parsed_url.rs @@ -58,11 +58,10 @@ impl UrlExtension for Url { I::Item: AsRef, { // Drop the trailing slash, so that `foo/` and `bar` turn into `foo/bar` instead of `foo//bar`. - if let Some(mut segments) = self.path_segments() { - if segments.next_back() == Some("") { + if let Some(mut segments) = self.path_segments() + && segments.next_back() == Some("") { self.path_segments_mut()?.pop(); } - } self.path_segments_mut()?.extend(segments); Ok(self) @@ -121,7 +120,7 @@ pub enum ParseUrlError { } impl WpSupportsLocalization for ParseUrlError { - fn message_bundle(&self) -> MessageBundle { + fn message_bundle(&self) -> MessageBundle<'_> { WpMessages::url_parsing_error() } } diff --git a/wp_api/src/request.rs b/wp_api/src/request.rs index 3b0be0215..0a435db1f 100644 --- a/wp_api/src/request.rs +++ b/wp_api/src/request.rs @@ -431,7 +431,7 @@ pub enum WpNetworkHeaderMapError { } impl WpSupportsLocalization for WpNetworkHeaderMapError { - fn message_bundle(&self) -> MessageBundle { + fn message_bundle(&self) -> MessageBundle<'_> { match self { WpNetworkHeaderMapError::InvalidHeaderName { header_name } => { WpMessages::invalid_header_name_error(header_name) @@ -638,7 +638,7 @@ pub enum HttpAuthMethodParsingError { } impl WpSupportsLocalization for HttpAuthMethodParsingError { - fn message_bundle(&self) -> MessageBundle { + fn message_bundle(&self) -> MessageBundle<'_> { match self { HttpAuthMethodParsingError::MissingNonce => { WpMessages::http_auth_method_missing_nonce() diff --git a/wp_api/src/uniffi_serde.rs b/wp_api/src/uniffi_serde.rs index 48d2f6ad4..25b8cf23b 100644 --- a/wp_api/src/uniffi_serde.rs +++ b/wp_api/src/uniffi_serde.rs @@ -7,7 +7,7 @@ pub enum UniffiSerializationError { } impl WpSupportsLocalization for UniffiSerializationError { - fn message_bundle(&self) -> MessageBundle { + fn message_bundle(&self) -> MessageBundle<'_> { match self { UniffiSerializationError::Serde { reason } => { WpMessages::uniffi_serialization_error_serde(reason) diff --git a/wp_api/src/uuid.rs b/wp_api/src/uuid.rs index 2c3516655..b28647d42 100644 --- a/wp_api/src/uuid.rs +++ b/wp_api/src/uuid.rs @@ -27,7 +27,7 @@ pub enum WpUuidParseError { } impl WpSupportsLocalization for WpUuidParseError { - fn message_bundle(&self) -> MessageBundle { + fn message_bundle(&self) -> MessageBundle<'_> { match self { WpUuidParseError::InvalidUuid => WpMessages::uuid_parse_error_invalid_uuid(), WpUuidParseError::NotVersion4 => WpMessages::uuid_parse_error_not_version_4(), diff --git a/wp_api/src/wordpress_org/client.rs b/wp_api/src/wordpress_org/client.rs index 4d6b734ea..b92a895f6 100644 --- a/wp_api/src/wordpress_org/client.rs +++ b/wp_api/src/wordpress_org/client.rs @@ -214,7 +214,7 @@ pub enum WordPressOrgApiClientError { } impl WpSupportsLocalization for WordPressOrgApiClientError { - fn message_bundle(&self) -> MessageBundle { + fn message_bundle(&self) -> MessageBundle<'_> { match self { WordPressOrgApiClientError::RequestEncodingError { reason } => { WpMessages::wordpress_org_api_client_error_request_encoding(reason) diff --git a/wp_derive/src/wp_deserialize.rs b/wp_derive/src/wp_deserialize.rs index 13bc81642..85f6b5819 100644 --- a/wp_derive/src/wp_deserialize.rs +++ b/wp_derive/src/wp_deserialize.rs @@ -146,24 +146,21 @@ impl ParsedStruct { fn parse_outer(input: ParseStream) -> syn::Result> { let attrs = Attribute::parse_outer(input)?; for attr in &attrs { - if let syn::Meta::List(meta_list) = &attr.meta { - if let Some(ident) = meta_list.path.get_ident() { + if let syn::Meta::List(meta_list) = &attr.meta + && let Some(ident) = meta_list.path.get_ident() { if *ident != "serde" { continue; } if let Some(proc_macro2::TokenTree::Ident(first_token_ident)) = meta_list.tokens.clone().into_iter().next() - { - if first_token_ident.to_string().as_str() == "transparent" { + && first_token_ident.to_string().as_str() == "transparent" { return Err( WpDeserializeParseError::SerdeTransparentAttributeNotSupported .into_syn_error(first_token_ident.span()), ); } - } } - } } Ok(attrs) } diff --git a/wp_derive_request_builder/src/variant_attr.rs b/wp_derive_request_builder/src/variant_attr.rs index 4a878bd51..a9b01208d 100644 --- a/wp_derive_request_builder/src/variant_attr.rs +++ b/wp_derive_request_builder/src/variant_attr.rs @@ -145,13 +145,12 @@ impl ParsedVariantAttribute { let mut collection = vec![]; let mut temp_v = vec![]; for t in tokens { - if let TokenTree::Punct(ref p) = t { - if p.as_char() == ',' { + if let TokenTree::Punct(ref p) = t + && p.as_char() == ',' { collection.push(temp_v); temp_v = vec![]; continue; } - } temp_v.push(t); } // Tokens after the final ',' diff --git a/wp_serde_helper/src/wp_serde_date.rs b/wp_serde_helper/src/wp_serde_date.rs index 9905dc8d8..ad9d5bee9 100644 --- a/wp_serde_helper/src/wp_serde_date.rs +++ b/wp_serde_helper/src/wp_serde_date.rs @@ -40,11 +40,10 @@ pub mod wp_utc_date_format { } // Unix Timestamp (wrapped in a string) - if let Ok(timestamp) = s.parse::() { - if let Some(dt) = DateTime::::from_timestamp(timestamp, 0) { + if let Ok(timestamp) = s.parse::() + && let Some(dt) = DateTime::::from_timestamp(timestamp, 0) { return Ok(dt); } - } // MySQL format if let Ok(dt) = NaiveDateTime::parse_from_str(&s, MYSQL_DATE_FORMAT) { From 6afa3848e35ed8773af278ccfaa2e8793968ee99 Mon Sep 17 00:00:00 2001 From: Oguz Kocer Date: Wed, 27 Aug 2025 23:13:28 -0400 Subject: [PATCH 3/3] make fmt-rust --- wp_api/src/jetpack/connection.rs | 7 ++--- wp_api/src/login.rs | 9 ++++--- wp_api/src/login/url_discovery.rs | 4 +-- wp_api/src/parsed_url.rs | 7 ++--- wp_derive/src/wp_deserialize.rs | 26 ++++++++++--------- wp_derive_request_builder/src/variant_attr.rs | 11 ++++---- wp_serde_helper/src/wp_serde_date.rs | 7 ++--- 7 files changed, 39 insertions(+), 32 deletions(-) diff --git a/wp_api/src/jetpack/connection.rs b/wp_api/src/jetpack/connection.rs index 73b421747..ab7164091 100644 --- a/wp_api/src/jetpack/connection.rs +++ b/wp_api/src/jetpack/connection.rs @@ -204,9 +204,10 @@ impl JetpackConnectionClient { error_code: WpErrorCode::CustomError(code), .. }) = &result - && (code == "success" || code == "already_connected") { - return Ok(blog_id); - } + && (code == "success" || code == "already_connected") + { + return Ok(blog_id); + } let result = result .map_err(JetpackConnectionClientError::Unhandled)? diff --git a/wp_api/src/login.rs b/wp_api/src/login.rs index a708dd18d..70a8fd662 100644 --- a/wp_api/src/login.rs +++ b/wp_api/src/login.rs @@ -37,9 +37,10 @@ pub fn extract_login_details_from_parsed_url( .find_map(|(k, v)| (k == key).then_some(v.to_string())) }; if let Some(is_success) = f("success") - && is_success == "false" { - return Err(OAuthResponseUrlError::UnsuccessfulLogin); - } + && is_success == "false" + { + return Err(OAuthResponseUrlError::UnsuccessfulLogin); + } let site_url = f("site_url").ok_or(OAuthResponseUrlError::MissingSiteUrl)?; let user_login = f("user_login").ok_or(OAuthResponseUrlError::MissingUsername)?; let password = f("password").ok_or(OAuthResponseUrlError::MissingPassword)?; @@ -209,7 +210,7 @@ pub enum OAuthResponseUrlError { } impl WpSupportsLocalization for OAuthResponseUrlError { - fn message_bundle(&self) -> MessageBundle { + fn message_bundle(&self) -> MessageBundle<'_> { match self { OAuthResponseUrlError::MissingSiteUrl | OAuthResponseUrlError::MissingUsername diff --git a/wp_api/src/login/url_discovery.rs b/wp_api/src/login/url_discovery.rs index bce0437e7..cb29e8fdf 100644 --- a/wp_api/src/login/url_discovery.rs +++ b/wp_api/src/login/url_discovery.rs @@ -486,7 +486,7 @@ pub enum FetchAndParseApiRootFailure { } impl FetchAndParseApiRootFailure { - fn message_bundle(&self, parsed_site_url: impl std::fmt::Display) -> MessageBundle { + fn message_bundle(&self, parsed_site_url: impl std::fmt::Display) -> MessageBundle<'_> { match self { Self::FetchApiRoot { error } => error.message_bundle(), Self::ParseApiRoot { reason, .. } => { @@ -530,7 +530,7 @@ pub enum ApplicationPasswordsNotSupportedReason { } impl ApplicationPasswordsNotSupportedReason { - fn message_bundle(&self, parsed_site_url: impl std::fmt::Display) -> MessageBundle { + fn message_bundle(&self, parsed_site_url: impl std::fmt::Display) -> MessageBundle<'_> { match self { Self::ApplicationPasswordBlockedByPlugin { plugin } => { WpMessages::application_password_blocked_by_plugin( diff --git a/wp_api/src/parsed_url.rs b/wp_api/src/parsed_url.rs index 86dfde2e5..b7951a0f5 100644 --- a/wp_api/src/parsed_url.rs +++ b/wp_api/src/parsed_url.rs @@ -59,9 +59,10 @@ impl UrlExtension for Url { { // Drop the trailing slash, so that `foo/` and `bar` turn into `foo/bar` instead of `foo//bar`. if let Some(mut segments) = self.path_segments() - && segments.next_back() == Some("") { - self.path_segments_mut()?.pop(); - } + && segments.next_back() == Some("") + { + self.path_segments_mut()?.pop(); + } self.path_segments_mut()?.extend(segments); Ok(self) diff --git a/wp_derive/src/wp_deserialize.rs b/wp_derive/src/wp_deserialize.rs index 85f6b5819..abcb873f0 100644 --- a/wp_derive/src/wp_deserialize.rs +++ b/wp_derive/src/wp_deserialize.rs @@ -147,20 +147,22 @@ impl ParsedStruct { let attrs = Attribute::parse_outer(input)?; for attr in &attrs { if let syn::Meta::List(meta_list) = &attr.meta - && let Some(ident) = meta_list.path.get_ident() { - if *ident != "serde" { - continue; - } + && let Some(ident) = meta_list.path.get_ident() + { + if *ident != "serde" { + continue; + } - if let Some(proc_macro2::TokenTree::Ident(first_token_ident)) = - meta_list.tokens.clone().into_iter().next() - && first_token_ident.to_string().as_str() == "transparent" { - return Err( - WpDeserializeParseError::SerdeTransparentAttributeNotSupported - .into_syn_error(first_token_ident.span()), - ); - } + if let Some(proc_macro2::TokenTree::Ident(first_token_ident)) = + meta_list.tokens.clone().into_iter().next() + && first_token_ident.to_string().as_str() == "transparent" + { + return Err( + WpDeserializeParseError::SerdeTransparentAttributeNotSupported + .into_syn_error(first_token_ident.span()), + ); } + } } Ok(attrs) } diff --git a/wp_derive_request_builder/src/variant_attr.rs b/wp_derive_request_builder/src/variant_attr.rs index a9b01208d..ed6faccf2 100644 --- a/wp_derive_request_builder/src/variant_attr.rs +++ b/wp_derive_request_builder/src/variant_attr.rs @@ -146,11 +146,12 @@ impl ParsedVariantAttribute { let mut temp_v = vec![]; for t in tokens { if let TokenTree::Punct(ref p) = t - && p.as_char() == ',' { - collection.push(temp_v); - temp_v = vec![]; - continue; - } + && p.as_char() == ',' + { + collection.push(temp_v); + temp_v = vec![]; + continue; + } temp_v.push(t); } // Tokens after the final ',' diff --git a/wp_serde_helper/src/wp_serde_date.rs b/wp_serde_helper/src/wp_serde_date.rs index ad9d5bee9..14d31f9b2 100644 --- a/wp_serde_helper/src/wp_serde_date.rs +++ b/wp_serde_helper/src/wp_serde_date.rs @@ -41,9 +41,10 @@ pub mod wp_utc_date_format { // Unix Timestamp (wrapped in a string) if let Ok(timestamp) = s.parse::() - && let Some(dt) = DateTime::::from_timestamp(timestamp, 0) { - return Ok(dt); - } + && let Some(dt) = DateTime::::from_timestamp(timestamp, 0) + { + return Ok(dt); + } // MySQL format if let Ok(dt) = NaiveDateTime::parse_from_str(&s, MYSQL_DATE_FORMAT) {