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_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..ab7164091 100644 --- a/wp_api/src/jetpack/connection.rs +++ b/wp_api/src/jetpack/connection.rs @@ -204,10 +204,9 @@ impl JetpackConnectionClient { error_code: WpErrorCode::CustomError(code), .. }) = &result + && (code == "success" || code == "already_connected") { - if code == "success" || code == "already_connected" { - return Ok(blog_id); - } + return Ok(blog_id); } let result = result 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..70a8fd662 100644 --- a/wp_api/src/login.rs +++ b/wp_api/src/login.rs @@ -36,10 +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" { - return Err(OAuthResponseUrlError::UnsuccessfulLogin); - } + 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)?; @@ -210,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 f73884e5d..cb29e8fdf 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(), @@ -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( @@ -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..b7951a0f5 100644 --- a/wp_api/src/parsed_url.rs +++ b/wp_api/src/parsed_url.rs @@ -58,10 +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("") { - self.path_segments_mut()?.pop(); - } + if let Some(mut segments) = self.path_segments() + && segments.next_back() == Some("") + { + self.path_segments_mut()?.pop(); } self.path_segments_mut()?.extend(segments); @@ -121,7 +121,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..abcb873f0 100644 --- a/wp_derive/src/wp_deserialize.rs +++ b/wp_derive/src/wp_deserialize.rs @@ -146,22 +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 *ident != "serde" { - continue; - } + 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" { - 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()), + ); } } } diff --git a/wp_derive_request_builder/src/variant_attr.rs b/wp_derive_request_builder/src/variant_attr.rs index 4a878bd51..ed6faccf2 100644 --- a/wp_derive_request_builder/src/variant_attr.rs +++ b/wp_derive_request_builder/src/variant_attr.rs @@ -145,12 +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() == ',' { - collection.push(temp_v); - temp_v = vec![]; - continue; - } + if let TokenTree::Punct(ref p) = t + && p.as_char() == ',' + { + collection.push(temp_v); + temp_v = vec![]; + continue; } temp_v.push(t); } 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 diff --git a/wp_serde_helper/src/wp_serde_date.rs b/wp_serde_helper/src/wp_serde_date.rs index 9905dc8d8..14d31f9b2 100644 --- a/wp_serde_helper/src/wp_serde_date.rs +++ b/wp_serde_helper/src/wp_serde_date.rs @@ -40,10 +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) { - return Ok(dt); - } + if let Ok(timestamp) = s.parse::() + && let Some(dt) = DateTime::::from_timestamp(timestamp, 0) + { + return Ok(dt); } // MySQL format