diff --git a/crates/crates_io_cdn_logs/Cargo.toml b/crates/crates_io_cdn_logs/Cargo.toml index b66bc48e949..4ae26044248 100644 --- a/crates/crates_io_cdn_logs/Cargo.toml +++ b/crates/crates_io_cdn_logs/Cargo.toml @@ -2,7 +2,7 @@ name = "crates_io_cdn_logs" version = "0.0.0" license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" [lints] workspace = true diff --git a/crates/crates_io_cdn_logs/benches/count_downloads.rs b/crates/crates_io_cdn_logs/benches/count_downloads.rs index 16347c65df1..4cbdf089414 100644 --- a/crates/crates_io_cdn_logs/benches/count_downloads.rs +++ b/crates/crates_io_cdn_logs/benches/count_downloads.rs @@ -1,5 +1,5 @@ use crates_io_cdn_logs::{cloudfront, fastly}; -use criterion::{criterion_group, criterion_main, Criterion}; +use criterion::{Criterion, criterion_group, criterion_main}; use std::hint::black_box; use std::io::Cursor; diff --git a/crates/crates_io_cdn_logs/examples/count_downloads.rs b/crates/crates_io_cdn_logs/examples/count_downloads.rs index bf5fa23488e..15fcd1bebff 100644 --- a/crates/crates_io_cdn_logs/examples/count_downloads.rs +++ b/crates/crates_io_cdn_logs/examples/count_downloads.rs @@ -1,11 +1,11 @@ use anyhow::Context; use clap::Parser; -use crates_io_cdn_logs::{count_downloads, Decompressor}; +use crates_io_cdn_logs::{Decompressor, count_downloads}; use std::path::PathBuf; use tokio::fs::File; use tokio::io::BufReader; use tracing::level_filters::LevelFilter; -use tracing_subscriber::{fmt, EnvFilter}; +use tracing_subscriber::{EnvFilter, fmt}; #[derive(Debug, clap::Parser)] struct Options { diff --git a/crates/crates_io_cdn_logs/src/cloudfront.rs b/crates/crates_io_cdn_logs/src/cloudfront.rs index fb52d42d5dc..dfe1f454f00 100644 --- a/crates/crates_io_cdn_logs/src/cloudfront.rs +++ b/crates/crates_io_cdn_logs/src/cloudfront.rs @@ -3,8 +3,8 @@ //! see //! and . -use crate::paths::parse_path; use crate::DownloadsMap; +use crate::paths::parse_path; use chrono::NaiveDate; use std::borrow::Cow; use tokio::io::{AsyncBufRead, AsyncBufReadExt}; diff --git a/crates/crates_io_cdn_logs/src/fastly/mod.rs b/crates/crates_io_cdn_logs/src/fastly/mod.rs index 3296036bee0..bd9d98547ee 100644 --- a/crates/crates_io_cdn_logs/src/fastly/mod.rs +++ b/crates/crates_io_cdn_logs/src/fastly/mod.rs @@ -4,8 +4,8 @@ mod json; -use crate::paths::parse_path; use crate::DownloadsMap; +use crate::paths::parse_path; use std::borrow::Cow; use tokio::io::{AsyncBufRead, AsyncBufReadExt}; use tracing::{debug_span, instrument, warn}; diff --git a/crates/crates_io_database/Cargo.toml b/crates/crates_io_database/Cargo.toml index 03a242c93d8..5bf0084a6ce 100644 --- a/crates/crates_io_database/Cargo.toml +++ b/crates/crates_io_database/Cargo.toml @@ -2,7 +2,7 @@ name = "crates_io_database" version = "0.0.0" license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" [lints] workspace = true diff --git a/crates/crates_io_database/src/models/category.rs b/crates/crates_io_database/src/models/category.rs index 2692471654e..de5002bc136 100644 --- a/crates/crates_io_database/src/models/category.rs +++ b/crates/crates_io_database/src/models/category.rs @@ -5,9 +5,8 @@ use diesel::dsl; use diesel::prelude::*; use diesel_async::scoped_futures::ScopedFutureExt; use diesel_async::{AsyncConnection, AsyncPgConnection, RunQueryDsl}; -use futures_util::future::BoxFuture; use futures_util::FutureExt; -use std::future::Future; +use futures_util::future::BoxFuture; #[derive(Clone, Identifiable, Queryable, QueryableByName, Debug, Selectable)] #[diesel(table_name = categories, check_for_backend(diesel::pg::Pg))] @@ -97,12 +96,12 @@ impl Category { .await } - pub fn toplevel( + pub fn toplevel<'a>( conn: &mut AsyncPgConnection, - sort: &str, + sort: &'a str, limit: i64, offset: i64, - ) -> impl Future>> { + ) -> BoxFuture<'a, QueryResult>> { use diesel::sql_types::Int8; let sort_sql = match sort { @@ -116,6 +115,7 @@ impl Category { .bind::(limit) .bind::(offset) .load(conn) + .boxed() } pub fn subcategories( diff --git a/crates/crates_io_database/src/models/token.rs b/crates/crates_io_database/src/models/token.rs index 20c3c1c01b9..1a2ba06b673 100644 --- a/crates/crates_io_database/src/models/token.rs +++ b/crates/crates_io_database/src/models/token.rs @@ -145,8 +145,9 @@ mod tests { }; let json = serde_json::to_string(&tok).unwrap(); assert_some!(json.as_str().find(r#""created_at":"2017-01-06T14:23:11Z""#)); - assert_some!(json - .as_str() - .find(r#""last_used_at":"2017-01-06T14:23:12Z""#)); + assert_some!( + json.as_str() + .find(r#""last_used_at":"2017-01-06T14:23:12Z""#) + ); } } diff --git a/crates/crates_io_database_dump/Cargo.toml b/crates/crates_io_database_dump/Cargo.toml index a56d462831e..a59e9864ad0 100644 --- a/crates/crates_io_database_dump/Cargo.toml +++ b/crates/crates_io_database_dump/Cargo.toml @@ -2,7 +2,7 @@ name = "crates_io_database_dump" version = "0.0.0" license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" [lints] workspace = true diff --git a/crates/crates_io_database_dump/src/configuration.rs b/crates/crates_io_database_dump/src/configuration.rs index 6c11b8eddd2..35989893204 100644 --- a/crates/crates_io_database_dump/src/configuration.rs +++ b/crates/crates_io_database_dump/src/configuration.rs @@ -53,7 +53,7 @@ impl VisibilityConfig { } let mut ready: VecDeque<&str> = num_deps .iter() - .filter(|(_, &count)| count == 0) + .filter(|&(_, &count)| count == 0) .map(|(&table, _)| table) .collect(); let mut result = Vec::with_capacity(ready.len()); diff --git a/crates/crates_io_database_dump/src/lib.rs b/crates/crates_io_database_dump/src/lib.rs index 803711e2075..c1f9e06c04a 100644 --- a/crates/crates_io_database_dump/src/lib.rs +++ b/crates/crates_io_database_dump/src/lib.rs @@ -1,6 +1,6 @@ #![doc = include_str!("../README.md")] -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use serde::Serialize; use std::fs; use std::fs::File; diff --git a/crates/crates_io_diesel_helpers/Cargo.toml b/crates/crates_io_diesel_helpers/Cargo.toml index 03f75c416d1..8601229b6ff 100644 --- a/crates/crates_io_diesel_helpers/Cargo.toml +++ b/crates/crates_io_diesel_helpers/Cargo.toml @@ -2,7 +2,7 @@ name = "crates_io_diesel_helpers" version = "0.0.0" license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" [lints] workspace = true diff --git a/crates/crates_io_diesel_helpers/src/semver.rs b/crates/crates_io_diesel_helpers/src/semver.rs index 6b37133ce29..ddd1e6acb15 100644 --- a/crates/crates_io_diesel_helpers/src/semver.rs +++ b/crates/crates_io_diesel_helpers/src/semver.rs @@ -1,6 +1,6 @@ +use diesel::Queryable; use diesel::pg::Pg; use diesel::sql_types::Text; -use diesel::Queryable; /// A wrapper around `semver::Version` that implements `diesel::Queryable`. /// diff --git a/crates/crates_io_env_vars/Cargo.toml b/crates/crates_io_env_vars/Cargo.toml index dd795e8d857..a3059a41fb9 100644 --- a/crates/crates_io_env_vars/Cargo.toml +++ b/crates/crates_io_env_vars/Cargo.toml @@ -2,7 +2,7 @@ name = "crates_io_env_vars" version = "0.0.0" license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" [lints] workspace = true diff --git a/crates/crates_io_env_vars/src/lib.rs b/crates/crates_io_env_vars/src/lib.rs index e467554fc34..0d349b4d784 100644 --- a/crates/crates_io_env_vars/src/lib.rs +++ b/crates/crates_io_env_vars/src/lib.rs @@ -1,6 +1,6 @@ #![doc = include_str!("../README.md")] -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use std::error::Error; use std::str::FromStr; @@ -139,10 +139,10 @@ mod tests { fn test_var() { let _guard = MUTEX.lock().unwrap(); - std::env::set_var(TEST_VAR, "test"); + unsafe { std::env::set_var(TEST_VAR, "test") }; assert_some_eq!(assert_ok!(var(TEST_VAR)), "test"); - std::env::remove_var(TEST_VAR); + unsafe { std::env::remove_var(TEST_VAR) }; assert_none!(assert_ok!(var(TEST_VAR))); } @@ -150,10 +150,10 @@ mod tests { fn test_required_var() { let _guard = MUTEX.lock().unwrap(); - std::env::set_var(TEST_VAR, "test"); + unsafe { std::env::set_var(TEST_VAR, "test") }; assert_ok_eq!(required_var(TEST_VAR), "test"); - std::env::remove_var(TEST_VAR); + unsafe { std::env::remove_var(TEST_VAR) }; let error = assert_err!(required_var(TEST_VAR)); assert_eq!( error.to_string(), @@ -165,17 +165,17 @@ mod tests { fn test_var_parsed() { let _guard = MUTEX.lock().unwrap(); - std::env::set_var(TEST_VAR, "42"); + unsafe { std::env::set_var(TEST_VAR, "42") }; assert_some_eq!(assert_ok!(var_parsed::(TEST_VAR)), 42); - std::env::set_var(TEST_VAR, "test"); + unsafe { std::env::set_var(TEST_VAR, "test") }; let error = assert_err!(var_parsed::(TEST_VAR)); assert_eq!( error.to_string(), "Failed to parse CRATES_IO_ENV_VARS_TEST_VAR environment variable" ); - std::env::remove_var(TEST_VAR); + unsafe { std::env::remove_var(TEST_VAR) }; assert_none!(assert_ok!(var_parsed::(TEST_VAR))); } @@ -183,17 +183,17 @@ mod tests { fn test_required_var_parsed() { let _guard = MUTEX.lock().unwrap(); - std::env::set_var(TEST_VAR, "42"); + unsafe { std::env::set_var(TEST_VAR, "42") }; assert_ok_eq!(required_var_parsed::(TEST_VAR), 42); - std::env::set_var(TEST_VAR, "test"); + unsafe { std::env::set_var(TEST_VAR, "test") }; let error = assert_err!(required_var_parsed::(TEST_VAR)); assert_eq!( error.to_string(), "Failed to parse CRATES_IO_ENV_VARS_TEST_VAR environment variable" ); - std::env::remove_var(TEST_VAR); + unsafe { std::env::remove_var(TEST_VAR) }; let error = assert_err!(required_var_parsed::(TEST_VAR)); assert_eq!( error.to_string(), @@ -205,16 +205,16 @@ mod tests { fn test_list() { let _guard = MUTEX.lock().unwrap(); - std::env::set_var(TEST_VAR, "test"); + unsafe { std::env::set_var(TEST_VAR, "test") }; assert_ok_eq!(list(TEST_VAR), vec!["test"]); - std::env::set_var(TEST_VAR, "test, foo, bar "); + unsafe { std::env::set_var(TEST_VAR, "test, foo, bar ") }; assert_ok_eq!(list(TEST_VAR), vec!["test", "foo", "bar"]); - std::env::set_var(TEST_VAR, ""); + unsafe { std::env::set_var(TEST_VAR, "") }; assert_ok_eq!(list(TEST_VAR), Vec::::new()); - std::env::remove_var(TEST_VAR); + unsafe { std::env::remove_var(TEST_VAR) }; assert_ok_eq!(list(TEST_VAR), Vec::::new()); } @@ -222,23 +222,23 @@ mod tests { fn test_list_parsed() { let _guard = MUTEX.lock().unwrap(); - std::env::set_var(TEST_VAR, "42"); + unsafe { std::env::set_var(TEST_VAR, "42") }; assert_ok_eq!(list_parsed(TEST_VAR, i32::from_str), vec![42]); - std::env::set_var(TEST_VAR, "42, 1, -53 "); + unsafe { std::env::set_var(TEST_VAR, "42, 1, -53 ") }; assert_ok_eq!(list_parsed(TEST_VAR, i32::from_str), vec![42, 1, -53]); - std::env::set_var(TEST_VAR, "42, what"); + unsafe { std::env::set_var(TEST_VAR, "42, what") }; let error = assert_err!(list_parsed(TEST_VAR, i32::from_str)); assert_eq!( error.to_string(), "Failed to parse value \"what\" of CRATES_IO_ENV_VARS_TEST_VAR environment variable" ); - std::env::set_var(TEST_VAR, ""); + unsafe { std::env::set_var(TEST_VAR, "") }; assert_ok_eq!(list_parsed(TEST_VAR, i32::from_str), Vec::::new()); - std::env::remove_var(TEST_VAR); + unsafe { std::env::remove_var(TEST_VAR) }; assert_ok_eq!(list_parsed(TEST_VAR, i32::from_str), Vec::::new()); } } diff --git a/crates/crates_io_github/Cargo.toml b/crates/crates_io_github/Cargo.toml index fa44150d9c0..2b141951692 100644 --- a/crates/crates_io_github/Cargo.toml +++ b/crates/crates_io_github/Cargo.toml @@ -2,7 +2,7 @@ name = "crates_io_github" version = "0.0.0" license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" [lints] workspace = true diff --git a/crates/crates_io_github/src/lib.rs b/crates/crates_io_github/src/lib.rs index 511faad6cc8..e7656bd70b5 100644 --- a/crates/crates_io_github/src/lib.rs +++ b/crates/crates_io_github/src/lib.rs @@ -4,7 +4,7 @@ extern crate tracing; use oauth2::AccessToken; -use reqwest::{self, header, RequestBuilder}; +use reqwest::{self, RequestBuilder, header}; use serde::de::DeserializeOwned; diff --git a/crates/crates_io_index/Cargo.toml b/crates/crates_io_index/Cargo.toml index 53bc615c2bb..5ee664afc5f 100644 --- a/crates/crates_io_index/Cargo.toml +++ b/crates/crates_io_index/Cargo.toml @@ -4,7 +4,7 @@ version = "0.0.0" license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/crates.io" description = "crates.io package index utilities" -edition = "2021" +edition = "2024" [lints] workspace = true diff --git a/crates/crates_io_index/credentials.rs b/crates/crates_io_index/credentials.rs index 67672857e35..58b848fea01 100644 --- a/crates/crates_io_index/credentials.rs +++ b/crates/crates_io_index/credentials.rs @@ -1,4 +1,4 @@ -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use secrecy::{ExposeSecret, SecretString}; use std::io::Write; diff --git a/crates/crates_io_index/repo.rs b/crates/crates_io_index/repo.rs index dbe1b8fc12b..87fe276adba 100644 --- a/crates/crates_io_index/repo.rs +++ b/crates/crates_io_index/repo.rs @@ -1,6 +1,6 @@ use crate::credentials::Credentials; -use anyhow::{anyhow, Context}; -use base64::{engine::general_purpose, Engine}; +use anyhow::{Context, anyhow}; +use base64::{Engine, engine::general_purpose}; use crates_io_env_vars::{required_var, required_var_parsed, var}; use secrecy::{ExposeSecret, SecretString}; use std::path::{Path, PathBuf}; diff --git a/crates/crates_io_index/ser.rs b/crates/crates_io_index/ser.rs index cb3beeee9b2..4ea7a623051 100644 --- a/crates/crates_io_index/ser.rs +++ b/crates/crates_io_index/ser.rs @@ -35,9 +35,12 @@ mod tests { }; let mut buffer = Vec::new(); assert_ok!(write_crate(&krate, &mut buffer)); - assert_ok_eq!(String::from_utf8(buffer), "\ + assert_ok_eq!( + String::from_utf8(buffer), + "\ {\"name\":\"foo\",\"vers\":\"1.2.3\",\"deps\":[],\"cksum\":\"0123456789asbcdef\",\"features\":{},\"yanked\":null}\n\ - "); + " + ); } #[test] @@ -61,11 +64,14 @@ mod tests { let mut buffer = Vec::new(); assert_ok!(write_crates(&crates, &mut buffer)); - assert_ok_eq!(String::from_utf8(buffer), "\ + assert_ok_eq!( + String::from_utf8(buffer), + "\ {\"name\":\"foo\",\"vers\":\"0.1.0\",\"deps\":[],\"cksum\":\"0123456789asbcdef\",\"features\":{},\"yanked\":null}\n\ {\"name\":\"foo\",\"vers\":\"1.0.0-beta.1\",\"deps\":[],\"cksum\":\"0123456789asbcdef\",\"features\":{},\"yanked\":null}\n\ {\"name\":\"foo\",\"vers\":\"1.0.0\",\"deps\":[],\"cksum\":\"0123456789asbcdef\",\"features\":{},\"yanked\":null}\n\ {\"name\":\"foo\",\"vers\":\"1.2.3\",\"deps\":[],\"cksum\":\"0123456789asbcdef\",\"features\":{},\"yanked\":null}\n\ - "); + " + ); } } diff --git a/crates/crates_io_markdown/Cargo.toml b/crates/crates_io_markdown/Cargo.toml index b62f8cff3de..c43ea354c03 100644 --- a/crates/crates_io_markdown/Cargo.toml +++ b/crates/crates_io_markdown/Cargo.toml @@ -4,7 +4,7 @@ version = "0.0.0" license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/crates.io" description = "crates.io markdown renderer" -edition = "2021" +edition = "2024" [lints] workspace = true diff --git a/crates/crates_io_markdown/lib.rs b/crates/crates_io_markdown/lib.rs index 1667ac5b4f6..53c890080d9 100644 --- a/crates/crates_io_markdown/lib.rs +++ b/crates/crates_io_markdown/lib.rs @@ -67,8 +67,8 @@ impl<'a> MarkdownRenderer<'a> { /// Renders the given markdown to HTML using the current settings. fn to_html(&self, text: &str) -> String { use comrak::{ - format_html, parse_document, Arena, ComrakExtensionOptions, ComrakOptions, - ComrakRenderOptions, + Arena, ComrakExtensionOptions, ComrakOptions, ComrakRenderOptions, format_html, + parse_document, }; let render_options = ComrakRenderOptions::builder() @@ -566,8 +566,7 @@ There can also be some text in between! #[test] fn absolute_links_dont_get_resolved() { - let text = - "[![crates.io](https://img.shields.io/crates/v/clap.svg)](https://crates.io/crates/clap)"; + let text = "[![crates.io](https://img.shields.io/crates/v/clap.svg)](https://crates.io/crates/clap)"; let repository = "https://github.com/kbknapp/clap-rs/"; assert_snapshot!(markdown_to_html(text, Some(repository), ""), @r#"

crates.io

"#); } @@ -650,8 +649,7 @@ There can also be some text in between! #[test] fn image_alignment() { - let text = - "

\"\"

\n"; + let text = "

\"\"

\n"; assert_snapshot!(markdown_to_html(text, None, ""), @r#"

"#); } diff --git a/crates/crates_io_pagerduty/Cargo.toml b/crates/crates_io_pagerduty/Cargo.toml index 4aa1dbb33b5..b6d5251286f 100644 --- a/crates/crates_io_pagerduty/Cargo.toml +++ b/crates/crates_io_pagerduty/Cargo.toml @@ -2,7 +2,7 @@ name = "crates_io_pagerduty" version = "0.0.0" license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" [lints] workspace = true diff --git a/crates/crates_io_pagerduty/src/lib.rs b/crates/crates_io_pagerduty/src/lib.rs index 4921c37dfec..c13aca6ba47 100644 --- a/crates/crates_io_pagerduty/src/lib.rs +++ b/crates/crates_io_pagerduty/src/lib.rs @@ -1,7 +1,7 @@ #![doc = include_str!("../README.md")] -use anyhow::{anyhow, Result}; -use reqwest::{header, Client, StatusCode as Status}; +use anyhow::{Result, anyhow}; +use reqwest::{Client, StatusCode as Status, header}; use secrecy::{ExposeSecret, SecretString}; #[derive(serde::Serialize, Debug)] diff --git a/crates/crates_io_session/Cargo.toml b/crates/crates_io_session/Cargo.toml index e101591853d..260b0a186c9 100644 --- a/crates/crates_io_session/Cargo.toml +++ b/crates/crates_io_session/Cargo.toml @@ -2,7 +2,7 @@ name = "crates_io_session" version = "0.0.0" license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" [lints] workspace = true diff --git a/crates/crates_io_session/src/lib.rs b/crates/crates_io_session/src/lib.rs index 03a5ed0c2cd..21b060df774 100644 --- a/crates/crates_io_session/src/lib.rs +++ b/crates/crates_io_session/src/lib.rs @@ -4,7 +4,7 @@ use axum::extract::{Extension, FromRequestParts, Request}; use axum::middleware::Next; use axum::response::{IntoResponse, Response}; use axum_extra::extract::SignedCookieJar; -use base64::{engine::general_purpose, Engine}; +use base64::{Engine, engine::general_purpose}; use cookie::time::Duration; use cookie::{Cookie, SameSite}; use parking_lot::RwLock; diff --git a/crates/crates_io_smoke_test/Cargo.toml b/crates/crates_io_smoke_test/Cargo.toml index 5b3904e88c5..ce478b35089 100644 --- a/crates/crates_io_smoke_test/Cargo.toml +++ b/crates/crates_io_smoke_test/Cargo.toml @@ -2,7 +2,7 @@ name = "crates_io_smoke_test" version = "0.0.0" license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" [lints] workspace = true diff --git a/crates/crates_io_smoke_test/src/main.rs b/crates/crates_io_smoke_test/src/main.rs index 1055adf04c8..587905acdf9 100644 --- a/crates/crates_io_smoke_test/src/main.rs +++ b/crates/crates_io_smoke_test/src/main.rs @@ -9,7 +9,7 @@ mod git; extern crate tracing; use crate::api::ApiClient; -use anyhow::{anyhow, bail, Context}; +use anyhow::{Context, anyhow, bail}; use clap::Parser; use secrecy::SecretString; use std::path::{Path, PathBuf}; @@ -177,7 +177,9 @@ async fn main() -> anyhow::Result<()> { } else { let stderr = String::from_utf8_lossy(&output.stderr); if !stderr.contains("413 Payload Too Large") { - bail!("Expected `cargo publish` to fail with an `413 Payload Too Large` error, but got:\n{stderr}"); + bail!( + "Expected `cargo publish` to fail with an `413 Payload Too Large` error, but got:\n{stderr}" + ); } } } diff --git a/crates/crates_io_tarball/Cargo.toml b/crates/crates_io_tarball/Cargo.toml index fe219dbb632..32b8d20c00b 100644 --- a/crates/crates_io_tarball/Cargo.toml +++ b/crates/crates_io_tarball/Cargo.toml @@ -2,7 +2,7 @@ name = "crates_io_tarball" version = "0.0.0" license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" [lints] workspace = true diff --git a/crates/crates_io_tarball/examples/check_all_crates.rs b/crates/crates_io_tarball/examples/check_all_crates.rs index fa87aaf8632..d0f52464233 100644 --- a/crates/crates_io_tarball/examples/check_all_crates.rs +++ b/crates/crates_io_tarball/examples/check_all_crates.rs @@ -1,14 +1,14 @@ use anyhow::anyhow; use clap::Parser; use crates_io_tarball::process_tarball; -use futures_util::{stream, StreamExt}; +use futures_util::{StreamExt, stream}; use indicatif::{ParallelProgressIterator, ProgressBar, ProgressIterator, ProgressStyle}; use rayon::prelude::*; use std::path::{Path, PathBuf}; use tokio::fs::File; use tracing::{debug, info, warn}; -use tracing_subscriber::filter::LevelFilter; use tracing_subscriber::EnvFilter; +use tracing_subscriber::filter::LevelFilter; use walkdir::WalkDir; /// Runs through all crate files in a folder and shows parsing errors. diff --git a/crates/crates_io_tarball/examples/read_file.rs b/crates/crates_io_tarball/examples/read_file.rs index 4a949fd7164..1e49db82f11 100644 --- a/crates/crates_io_tarball/examples/read_file.rs +++ b/crates/crates_io_tarball/examples/read_file.rs @@ -1,10 +1,10 @@ -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use clap::Parser; use crates_io_tarball::process_tarball; use std::path::PathBuf; use tokio::fs::File; -use tracing_subscriber::filter::LevelFilter; use tracing_subscriber::EnvFilter; +use tracing_subscriber::filter::LevelFilter; /// Read and process a `.crate` file the same way crates.io does when publishing a crate version. /// If the crate file has no errors, the metadata that would be written to the database will be diff --git a/crates/crates_io_tarball/src/builder.rs b/crates/crates_io_tarball/src/builder.rs index 4d89ac86bce..e82cfd6b1c8 100644 --- a/crates/crates_io_tarball/src/builder.rs +++ b/crates/crates_io_tarball/src/builder.rs @@ -1,5 +1,5 @@ -use flate2::read::GzEncoder; use flate2::Compression; +use flate2::read::GzEncoder; use std::io::Read; pub struct TarballBuilder { diff --git a/crates/crates_io_team_repo/Cargo.toml b/crates/crates_io_team_repo/Cargo.toml index 71b3a0ac9dd..bfabe9f202b 100644 --- a/crates/crates_io_team_repo/Cargo.toml +++ b/crates/crates_io_team_repo/Cargo.toml @@ -2,7 +2,7 @@ name = "crates_io_team_repo" version = "0.0.0" license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" [lints] workspace = true diff --git a/crates/crates_io_test_db/Cargo.toml b/crates/crates_io_test_db/Cargo.toml index 10344ffffec..dce702c3787 100644 --- a/crates/crates_io_test_db/Cargo.toml +++ b/crates/crates_io_test_db/Cargo.toml @@ -2,7 +2,7 @@ name = "crates_io_test_db" version = "0.0.0" license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" [lints] workspace = true diff --git a/crates/crates_io_worker/Cargo.toml b/crates/crates_io_worker/Cargo.toml index 0ed85bf19f5..dbb2d278402 100644 --- a/crates/crates_io_worker/Cargo.toml +++ b/crates/crates_io_worker/Cargo.toml @@ -2,7 +2,7 @@ name = "crates_io_worker" version = "0.0.0" license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" [lints] workspace = true diff --git a/crates/crates_io_worker/src/background_job.rs b/crates/crates_io_worker/src/background_job.rs index 60d187e2dc9..3f564ba7782 100644 --- a/crates/crates_io_worker/src/background_job.rs +++ b/crates/crates_io_worker/src/background_job.rs @@ -4,10 +4,10 @@ use diesel::dsl::{exists, not}; use diesel::sql_types::{Int2, Jsonb, Text}; use diesel::{ExpressionMethods, IntoSql, OptionalExtension, QueryDsl}; use diesel_async::{AsyncPgConnection, RunQueryDsl}; -use futures_util::future::BoxFuture; use futures_util::FutureExt; -use serde::de::DeserializeOwned; +use futures_util::future::BoxFuture; use serde::Serialize; +use serde::de::DeserializeOwned; use serde_json::Value; use std::future::Future; use tracing::instrument; @@ -61,12 +61,12 @@ pub trait BackgroundJob: Serialize + DeserializeOwned + Send + Sync + 'static { } } -fn enqueue_deduplicated( +fn enqueue_deduplicated<'a>( conn: &mut AsyncPgConnection, - job_type: &'static str, + job_type: &'a str, data: Value, priority: i16, -) -> impl Future, EnqueueError>> { +) -> BoxFuture<'a, Result, EnqueueError>> { let similar_jobs = background_jobs::table .select(background_jobs::id) .filter(background_jobs::job_type.eq(job_type)) @@ -92,15 +92,15 @@ fn enqueue_deduplicated( .returning(background_jobs::id) .get_result::(conn); - async move { Ok(future.await.optional()?) } + async move { Ok(future.await.optional()?) }.boxed() } -fn enqueue_simple( +fn enqueue_simple<'a>( conn: &mut AsyncPgConnection, - job_type: &'static str, + job_type: &'a str, data: Value, priority: i16, -) -> impl Future> { +) -> BoxFuture<'a, Result> { let future = diesel::insert_into(background_jobs::table) .values(( background_jobs::job_type.eq(job_type), @@ -110,5 +110,5 @@ fn enqueue_simple( .returning(background_jobs::id) .get_result(conn); - async move { Ok(future.await?) } + async move { Ok(future.await?) }.boxed() } diff --git a/crates/crates_io_worker/src/runner.rs b/crates/crates_io_worker/src/runner.rs index 95bbcbdfbdc..a3f82981282 100644 --- a/crates/crates_io_worker/src/runner.rs +++ b/crates/crates_io_worker/src/runner.rs @@ -1,16 +1,16 @@ use crate::background_job::DEFAULT_QUEUE; use crate::job_registry::JobRegistry; use crate::worker::Worker; -use crate::{storage, BackgroundJob}; +use crate::{BackgroundJob, storage}; use anyhow::anyhow; -use diesel_async::pooled_connection::deadpool::Pool; use diesel_async::AsyncPgConnection; +use diesel_async::pooled_connection::deadpool::Pool; use futures_util::future::join_all; use std::collections::HashMap; use std::sync::Arc; use std::time::Duration; use tokio::task::JoinHandle; -use tracing::{info, info_span, warn, Instrument}; +use tracing::{Instrument, info, info_span, warn}; const DEFAULT_POLL_INTERVAL: Duration = Duration::from_secs(1); diff --git a/crates/crates_io_worker/tests/runner.rs b/crates/crates_io_worker/tests/runner.rs index 88381ca7a78..a20a4c98e9a 100644 --- a/crates/crates_io_worker/tests/runner.rs +++ b/crates/crates_io_worker/tests/runner.rs @@ -3,14 +3,14 @@ use crates_io_test_db::TestDatabase; use crates_io_worker::schema::background_jobs; use crates_io_worker::{BackgroundJob, Runner}; use diesel::prelude::*; -use diesel_async::pooled_connection::deadpool::Pool; use diesel_async::pooled_connection::AsyncDieselConnectionManager; +use diesel_async::pooled_connection::deadpool::Pool; use diesel_async::{AsyncPgConnection, RunQueryDsl}; use insta::assert_compact_json_snapshot; use serde::{Deserialize, Serialize}; use serde_json::Value; -use std::sync::atomic::{AtomicU8, Ordering}; use std::sync::Arc; +use std::sync::atomic::{AtomicU8, Ordering}; use tokio::sync::Barrier; async fn all_jobs(conn: &mut AsyncPgConnection) -> QueryResult> {