From 1f8889e838dd5597c77b8d69a1edfffe6025286b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 28 Nov 2024 16:24:48 +0000 Subject: [PATCH 1/5] Update Rust to v1.83.0 --- backend.Dockerfile | 2 +- rust-toolchain.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/backend.Dockerfile b/backend.Dockerfile index dd7282bf823..4dc658751f4 100644 --- a/backend.Dockerfile +++ b/backend.Dockerfile @@ -1,5 +1,5 @@ # renovate: datasource=github-tags depName=rust lookupName=rust-lang/rust -ARG RUST_VERSION=1.82.0 +ARG RUST_VERSION=1.83.0 FROM rust:$RUST_VERSION diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 2e2b8c8521e..0193dee3606 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.82.0" +channel = "1.83.0" From 943e44bfab322ccb42a9897ef059a1c8b806636d Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Thu, 28 Nov 2024 18:09:54 +0100 Subject: [PATCH 2/5] Elide explicit lifetimes where unnecessary --- src/controllers/token.rs | 2 +- src/middleware/update_metrics.rs | 2 +- src/worker/jobs/expiry_notification.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/controllers/token.rs b/src/controllers/token.rs index bc3825eab53..8f6a4d2c301 100644 --- a/src/controllers/token.rs +++ b/src/controllers/token.rs @@ -214,7 +214,7 @@ struct NewTokenEmail<'a> { domain: &'a str, } -impl<'a> crate::email::Email for NewTokenEmail<'a> { +impl crate::email::Email for NewTokenEmail<'_> { fn subject(&self) -> String { format!("crates.io: New API token \"{}\" created", self.token_name) } diff --git a/src/middleware/update_metrics.rs b/src/middleware/update_metrics.rs index 2d979916be6..e74ec75d86c 100644 --- a/src/middleware/update_metrics.rs +++ b/src/middleware/update_metrics.rs @@ -51,7 +51,7 @@ impl<'a> GaugeGuard<'a> { } } -impl<'a> Drop for GaugeGuard<'a> { +impl Drop for GaugeGuard<'_> { fn drop(&mut self) { self.gauge.dec(); } diff --git a/src/worker/jobs/expiry_notification.rs b/src/worker/jobs/expiry_notification.rs index a578c77e06d..d622c525176 100644 --- a/src/worker/jobs/expiry_notification.rs +++ b/src/worker/jobs/expiry_notification.rs @@ -137,7 +137,7 @@ struct ExpiryNotificationEmail<'a> { expiry_date: chrono::DateTime, } -impl<'a> Email for ExpiryNotificationEmail<'a> { +impl Email for ExpiryNotificationEmail<'_> { fn subject(&self) -> String { format!( "crates.io: Your API token \"{}\" is about to expire", From ca0fb8adcea96b882f71891ff5a8e3721e969457 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Thu, 28 Nov 2024 18:10:11 +0100 Subject: [PATCH 3/5] Fix empty line after doc comment --- src/controllers/krate/versions.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/controllers/krate/versions.rs b/src/controllers/krate/versions.rs index 0caa32c941f..43761016122 100644 --- a/src/controllers/krate/versions.rs +++ b/src/controllers/krate/versions.rs @@ -173,12 +173,12 @@ async fn list_by_date( /// Seek-based pagination of versions by semver /// +/// Unfortunately, Heroku Postgres has no support for the semver PG extension. +/// Therefore, we need to perform both sorting and pagination manually on the server. +/// /// # Panics /// /// This function will panic if `option` is built with `enable_pages` set to true. - -// Unfortunately, Heroku Postgres has no support for the semver PG extension. -// Therefore, we need to perform both sorting and pagination manually on the server. async fn list_by_semver( crate_id: i32, options: Option<&PaginationOptions>, From a99b9573e303d5d1cccf8bdd9e2cd891f6de1691 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Thu, 28 Nov 2024 18:11:10 +0100 Subject: [PATCH 4/5] "Simplify" boolean expression if you say so, clippy... --- src/controllers/user/session.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/user/session.rs b/src/controllers/user/session.rs index 91a369e111f..e555573a1e4 100644 --- a/src/controllers/user/session.rs +++ b/src/controllers/user/session.rs @@ -91,7 +91,7 @@ pub async fn authorize( // Make sure that the state we just got matches the session state that we // should have issued earlier. let session_state = session.remove("github_oauth_state").map(CsrfToken::new); - if !session_state.is_some_and(|state| query.state.secret() == state.secret()) { + if session_state.is_none_or(|state| query.state.secret() != state.secret()) { return Err(bad_request("invalid state parameter")); } From efdd8fd7d86f7a2afa298673090093b3c49f9d6a Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Thu, 28 Nov 2024 18:11:33 +0100 Subject: [PATCH 5/5] Remove unnecessary `return` statements --- src/models/token/scopes.rs | 4 ++-- src/real_ip.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/models/token/scopes.rs b/src/models/token/scopes.rs index 8c426cc871d..a3b9579935f 100644 --- a/src/models/token/scopes.rs +++ b/src/models/token/scopes.rs @@ -116,10 +116,10 @@ impl CrateScope { return true; } - return match self.pattern.strip_suffix('*') { + match self.pattern.strip_suffix('*') { Some(prefix) => crate_name.starts_with(prefix), None => crate_name == self.pattern, - }; + } } } diff --git a/src/real_ip.rs b/src/real_ip.rs index 24edbf89bbd..111ac39edbc 100644 --- a/src/real_ip.rs +++ b/src/real_ip.rs @@ -46,7 +46,7 @@ pub fn process_xff_headers(headers: &HeaderMap) -> Option { }; let has_more_headers = xff_iter.next().is_some(); - return if has_more_headers { + if has_more_headers { // This only happens for requests going directly to crates-io.herokuapp.com, // since AWS CloudFront automatically merges these headers into one. // @@ -81,7 +81,7 @@ pub fn process_xff_headers(headers: &HeaderMap) -> Option { .filter_map(|r| r.ok()) .filter(|ip| !is_cloud_front_ip(ip)) .next_back() - }; + } } /// Parses the content of an `X-Forwarded-For` header into a