Skip to content

Commit f0c7895

Browse files
authored
Merge pull request #11208 from Turbo87/edition
Migrate subcrates to Rust Edition 2024
2 parents 8f1d3df + 2793e74 commit f0c7895

File tree

39 files changed

+97
-90
lines changed

39 files changed

+97
-90
lines changed

crates/crates_io_cdn_logs/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "crates_io_cdn_logs"
33
version = "0.0.0"
44
license = "MIT OR Apache-2.0"
5-
edition = "2021"
5+
edition = "2024"
66

77
[lints]
88
workspace = true

crates/crates_io_cdn_logs/benches/count_downloads.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crates_io_cdn_logs::{cloudfront, fastly};
2-
use criterion::{criterion_group, criterion_main, Criterion};
2+
use criterion::{Criterion, criterion_group, criterion_main};
33
use std::hint::black_box;
44
use std::io::Cursor;
55

crates/crates_io_cdn_logs/examples/count_downloads.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use anyhow::Context;
22
use clap::Parser;
3-
use crates_io_cdn_logs::{count_downloads, Decompressor};
3+
use crates_io_cdn_logs::{Decompressor, count_downloads};
44
use std::path::PathBuf;
55
use tokio::fs::File;
66
use tokio::io::BufReader;
77
use tracing::level_filters::LevelFilter;
8-
use tracing_subscriber::{fmt, EnvFilter};
8+
use tracing_subscriber::{EnvFilter, fmt};
99

1010
#[derive(Debug, clap::Parser)]
1111
struct Options {

crates/crates_io_cdn_logs/src/cloudfront.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
//! see <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/AccessLogs.html#LogFileFormat>
44
//! and <https://www.w3.org/TR/WD-logfile.html>.
55
6-
use crate::paths::parse_path;
76
use crate::DownloadsMap;
7+
use crate::paths::parse_path;
88
use chrono::NaiveDate;
99
use std::borrow::Cow;
1010
use tokio::io::{AsyncBufRead, AsyncBufReadExt};

crates/crates_io_cdn_logs/src/fastly/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
55
mod json;
66

7-
use crate::paths::parse_path;
87
use crate::DownloadsMap;
8+
use crate::paths::parse_path;
99
use std::borrow::Cow;
1010
use tokio::io::{AsyncBufRead, AsyncBufReadExt};
1111
use tracing::{debug_span, instrument, warn};

crates/crates_io_database/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "crates_io_database"
33
version = "0.0.0"
44
license = "MIT OR Apache-2.0"
5-
edition = "2021"
5+
edition = "2024"
66

77
[lints]
88
workspace = true

crates/crates_io_database/src/models/category.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ use diesel::dsl;
55
use diesel::prelude::*;
66
use diesel_async::scoped_futures::ScopedFutureExt;
77
use diesel_async::{AsyncConnection, AsyncPgConnection, RunQueryDsl};
8-
use futures_util::future::BoxFuture;
98
use futures_util::FutureExt;
10-
use std::future::Future;
9+
use futures_util::future::BoxFuture;
1110

1211
#[derive(Clone, Identifiable, Queryable, QueryableByName, Debug, Selectable)]
1312
#[diesel(table_name = categories, check_for_backend(diesel::pg::Pg))]
@@ -97,12 +96,12 @@ impl Category {
9796
.await
9897
}
9998

100-
pub fn toplevel(
99+
pub fn toplevel<'a>(
101100
conn: &mut AsyncPgConnection,
102-
sort: &str,
101+
sort: &'a str,
103102
limit: i64,
104103
offset: i64,
105-
) -> impl Future<Output = QueryResult<Vec<Category>>> {
104+
) -> BoxFuture<'a, QueryResult<Vec<Category>>> {
106105
use diesel::sql_types::Int8;
107106

108107
let sort_sql = match sort {
@@ -116,6 +115,7 @@ impl Category {
116115
.bind::<Int8, _>(limit)
117116
.bind::<Int8, _>(offset)
118117
.load(conn)
118+
.boxed()
119119
}
120120

121121
pub fn subcategories(

crates/crates_io_database/src/models/token.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,9 @@ mod tests {
145145
};
146146
let json = serde_json::to_string(&tok).unwrap();
147147
assert_some!(json.as_str().find(r#""created_at":"2017-01-06T14:23:11Z""#));
148-
assert_some!(json
149-
.as_str()
150-
.find(r#""last_used_at":"2017-01-06T14:23:12Z""#));
148+
assert_some!(
149+
json.as_str()
150+
.find(r#""last_used_at":"2017-01-06T14:23:12Z""#)
151+
);
151152
}
152153
}

crates/crates_io_database_dump/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "crates_io_database_dump"
33
version = "0.0.0"
44
license = "MIT OR Apache-2.0"
5-
edition = "2021"
5+
edition = "2024"
66

77
[lints]
88
workspace = true

crates/crates_io_database_dump/src/configuration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl VisibilityConfig {
5353
}
5454
let mut ready: VecDeque<&str> = num_deps
5555
.iter()
56-
.filter(|(_, &count)| count == 0)
56+
.filter(|&(_, &count)| count == 0)
5757
.map(|(&table, _)| table)
5858
.collect();
5959
let mut result = Vec::with_capacity(ready.len());

crates/crates_io_database_dump/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![doc = include_str!("../README.md")]
22

3-
use anyhow::{anyhow, Context};
3+
use anyhow::{Context, anyhow};
44
use serde::Serialize;
55
use std::fs;
66
use std::fs::File;

crates/crates_io_diesel_helpers/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "crates_io_diesel_helpers"
33
version = "0.0.0"
44
license = "MIT OR Apache-2.0"
5-
edition = "2021"
5+
edition = "2024"
66

77
[lints]
88
workspace = true

crates/crates_io_diesel_helpers/src/semver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
use diesel::Queryable;
12
use diesel::pg::Pg;
23
use diesel::sql_types::Text;
3-
use diesel::Queryable;
44

55
/// A wrapper around `semver::Version` that implements `diesel::Queryable`.
66
///

crates/crates_io_env_vars/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "crates_io_env_vars"
33
version = "0.0.0"
44
license = "MIT OR Apache-2.0"
5-
edition = "2021"
5+
edition = "2024"
66

77
[lints]
88
workspace = true

crates/crates_io_env_vars/src/lib.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![doc = include_str!("../README.md")]
22

3-
use anyhow::{anyhow, Context};
3+
use anyhow::{Context, anyhow};
44
use std::error::Error;
55
use std::str::FromStr;
66

@@ -139,21 +139,21 @@ mod tests {
139139
fn test_var() {
140140
let _guard = MUTEX.lock().unwrap();
141141

142-
std::env::set_var(TEST_VAR, "test");
142+
unsafe { std::env::set_var(TEST_VAR, "test") };
143143
assert_some_eq!(assert_ok!(var(TEST_VAR)), "test");
144144

145-
std::env::remove_var(TEST_VAR);
145+
unsafe { std::env::remove_var(TEST_VAR) };
146146
assert_none!(assert_ok!(var(TEST_VAR)));
147147
}
148148

149149
#[test]
150150
fn test_required_var() {
151151
let _guard = MUTEX.lock().unwrap();
152152

153-
std::env::set_var(TEST_VAR, "test");
153+
unsafe { std::env::set_var(TEST_VAR, "test") };
154154
assert_ok_eq!(required_var(TEST_VAR), "test");
155155

156-
std::env::remove_var(TEST_VAR);
156+
unsafe { std::env::remove_var(TEST_VAR) };
157157
let error = assert_err!(required_var(TEST_VAR));
158158
assert_eq!(
159159
error.to_string(),
@@ -165,35 +165,35 @@ mod tests {
165165
fn test_var_parsed() {
166166
let _guard = MUTEX.lock().unwrap();
167167

168-
std::env::set_var(TEST_VAR, "42");
168+
unsafe { std::env::set_var(TEST_VAR, "42") };
169169
assert_some_eq!(assert_ok!(var_parsed::<i32>(TEST_VAR)), 42);
170170

171-
std::env::set_var(TEST_VAR, "test");
171+
unsafe { std::env::set_var(TEST_VAR, "test") };
172172
let error = assert_err!(var_parsed::<i32>(TEST_VAR));
173173
assert_eq!(
174174
error.to_string(),
175175
"Failed to parse CRATES_IO_ENV_VARS_TEST_VAR environment variable"
176176
);
177177

178-
std::env::remove_var(TEST_VAR);
178+
unsafe { std::env::remove_var(TEST_VAR) };
179179
assert_none!(assert_ok!(var_parsed::<i32>(TEST_VAR)));
180180
}
181181

182182
#[test]
183183
fn test_required_var_parsed() {
184184
let _guard = MUTEX.lock().unwrap();
185185

186-
std::env::set_var(TEST_VAR, "42");
186+
unsafe { std::env::set_var(TEST_VAR, "42") };
187187
assert_ok_eq!(required_var_parsed::<i32>(TEST_VAR), 42);
188188

189-
std::env::set_var(TEST_VAR, "test");
189+
unsafe { std::env::set_var(TEST_VAR, "test") };
190190
let error = assert_err!(required_var_parsed::<i32>(TEST_VAR));
191191
assert_eq!(
192192
error.to_string(),
193193
"Failed to parse CRATES_IO_ENV_VARS_TEST_VAR environment variable"
194194
);
195195

196-
std::env::remove_var(TEST_VAR);
196+
unsafe { std::env::remove_var(TEST_VAR) };
197197
let error = assert_err!(required_var_parsed::<i32>(TEST_VAR));
198198
assert_eq!(
199199
error.to_string(),
@@ -205,40 +205,40 @@ mod tests {
205205
fn test_list() {
206206
let _guard = MUTEX.lock().unwrap();
207207

208-
std::env::set_var(TEST_VAR, "test");
208+
unsafe { std::env::set_var(TEST_VAR, "test") };
209209
assert_ok_eq!(list(TEST_VAR), vec!["test"]);
210210

211-
std::env::set_var(TEST_VAR, "test, foo, bar ");
211+
unsafe { std::env::set_var(TEST_VAR, "test, foo, bar ") };
212212
assert_ok_eq!(list(TEST_VAR), vec!["test", "foo", "bar"]);
213213

214-
std::env::set_var(TEST_VAR, "");
214+
unsafe { std::env::set_var(TEST_VAR, "") };
215215
assert_ok_eq!(list(TEST_VAR), Vec::<String>::new());
216216

217-
std::env::remove_var(TEST_VAR);
217+
unsafe { std::env::remove_var(TEST_VAR) };
218218
assert_ok_eq!(list(TEST_VAR), Vec::<String>::new());
219219
}
220220

221221
#[test]
222222
fn test_list_parsed() {
223223
let _guard = MUTEX.lock().unwrap();
224224

225-
std::env::set_var(TEST_VAR, "42");
225+
unsafe { std::env::set_var(TEST_VAR, "42") };
226226
assert_ok_eq!(list_parsed(TEST_VAR, i32::from_str), vec![42]);
227227

228-
std::env::set_var(TEST_VAR, "42, 1, -53 ");
228+
unsafe { std::env::set_var(TEST_VAR, "42, 1, -53 ") };
229229
assert_ok_eq!(list_parsed(TEST_VAR, i32::from_str), vec![42, 1, -53]);
230230

231-
std::env::set_var(TEST_VAR, "42, what");
231+
unsafe { std::env::set_var(TEST_VAR, "42, what") };
232232
let error = assert_err!(list_parsed(TEST_VAR, i32::from_str));
233233
assert_eq!(
234234
error.to_string(),
235235
"Failed to parse value \"what\" of CRATES_IO_ENV_VARS_TEST_VAR environment variable"
236236
);
237237

238-
std::env::set_var(TEST_VAR, "");
238+
unsafe { std::env::set_var(TEST_VAR, "") };
239239
assert_ok_eq!(list_parsed(TEST_VAR, i32::from_str), Vec::<i32>::new());
240240

241-
std::env::remove_var(TEST_VAR);
241+
unsafe { std::env::remove_var(TEST_VAR) };
242242
assert_ok_eq!(list_parsed(TEST_VAR, i32::from_str), Vec::<i32>::new());
243243
}
244244
}

crates/crates_io_github/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "crates_io_github"
33
version = "0.0.0"
44
license = "MIT OR Apache-2.0"
5-
edition = "2021"
5+
edition = "2024"
66

77
[lints]
88
workspace = true

crates/crates_io_github/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
extern crate tracing;
55

66
use oauth2::AccessToken;
7-
use reqwest::{self, header, RequestBuilder};
7+
use reqwest::{self, RequestBuilder, header};
88

99
use serde::de::DeserializeOwned;
1010

crates/crates_io_index/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.0.0"
44
license = "MIT OR Apache-2.0"
55
repository = "https://github.com/rust-lang/crates.io"
66
description = "crates.io package index utilities"
7-
edition = "2021"
7+
edition = "2024"
88

99
[lints]
1010
workspace = true

crates/crates_io_index/credentials.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use anyhow::{anyhow, Context};
1+
use anyhow::{Context, anyhow};
22
use secrecy::{ExposeSecret, SecretString};
33
use std::io::Write;
44

crates/crates_io_index/repo.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::credentials::Credentials;
2-
use anyhow::{anyhow, Context};
3-
use base64::{engine::general_purpose, Engine};
2+
use anyhow::{Context, anyhow};
3+
use base64::{Engine, engine::general_purpose};
44
use crates_io_env_vars::{required_var, required_var_parsed, var};
55
use secrecy::{ExposeSecret, SecretString};
66
use std::path::{Path, PathBuf};

crates/crates_io_index/ser.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,12 @@ mod tests {
3535
};
3636
let mut buffer = Vec::new();
3737
assert_ok!(write_crate(&krate, &mut buffer));
38-
assert_ok_eq!(String::from_utf8(buffer), "\
38+
assert_ok_eq!(
39+
String::from_utf8(buffer),
40+
"\
3941
{\"name\":\"foo\",\"vers\":\"1.2.3\",\"deps\":[],\"cksum\":\"0123456789asbcdef\",\"features\":{},\"yanked\":null}\n\
40-
");
42+
"
43+
);
4144
}
4245

4346
#[test]
@@ -61,11 +64,14 @@ mod tests {
6164

6265
let mut buffer = Vec::new();
6366
assert_ok!(write_crates(&crates, &mut buffer));
64-
assert_ok_eq!(String::from_utf8(buffer), "\
67+
assert_ok_eq!(
68+
String::from_utf8(buffer),
69+
"\
6570
{\"name\":\"foo\",\"vers\":\"0.1.0\",\"deps\":[],\"cksum\":\"0123456789asbcdef\",\"features\":{},\"yanked\":null}\n\
6671
{\"name\":\"foo\",\"vers\":\"1.0.0-beta.1\",\"deps\":[],\"cksum\":\"0123456789asbcdef\",\"features\":{},\"yanked\":null}\n\
6772
{\"name\":\"foo\",\"vers\":\"1.0.0\",\"deps\":[],\"cksum\":\"0123456789asbcdef\",\"features\":{},\"yanked\":null}\n\
6873
{\"name\":\"foo\",\"vers\":\"1.2.3\",\"deps\":[],\"cksum\":\"0123456789asbcdef\",\"features\":{},\"yanked\":null}\n\
69-
");
74+
"
75+
);
7076
}
7177
}

crates/crates_io_markdown/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.0.0"
44
license = "MIT OR Apache-2.0"
55
repository = "https://github.com/rust-lang/crates.io"
66
description = "crates.io markdown renderer"
7-
edition = "2021"
7+
edition = "2024"
88

99
[lints]
1010
workspace = true

crates/crates_io_markdown/lib.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ impl<'a> MarkdownRenderer<'a> {
6767
/// Renders the given markdown to HTML using the current settings.
6868
fn to_html(&self, text: &str) -> String {
6969
use comrak::{
70-
format_html, parse_document, Arena, ComrakExtensionOptions, ComrakOptions,
71-
ComrakRenderOptions,
70+
Arena, ComrakExtensionOptions, ComrakOptions, ComrakRenderOptions, format_html,
71+
parse_document,
7272
};
7373

7474
let render_options = ComrakRenderOptions::builder()
@@ -566,8 +566,7 @@ There can also be some text in between!
566566

567567
#[test]
568568
fn absolute_links_dont_get_resolved() {
569-
let text =
570-
"[![crates.io](https://img.shields.io/crates/v/clap.svg)](https://crates.io/crates/clap)";
569+
let text = "[![crates.io](https://img.shields.io/crates/v/clap.svg)](https://crates.io/crates/clap)";
571570
let repository = "https://github.com/kbknapp/clap-rs/";
572571
assert_snapshot!(markdown_to_html(text, Some(repository), ""), @r#"<p><a href="https://crates.io/crates/clap" rel="nofollow noopener noreferrer"><img src="https://img.shields.io/crates/v/clap.svg" alt="crates.io"></a></p>"#);
573572
}
@@ -650,8 +649,7 @@ There can also be some text in between!
650649

651650
#[test]
652651
fn image_alignment() {
653-
let text =
654-
"<p align=\"center\"><img src=\"https://img.shields.io/crates/v/clap.svg\" alt=\"\"></p>\n";
652+
let text = "<p align=\"center\"><img src=\"https://img.shields.io/crates/v/clap.svg\" alt=\"\"></p>\n";
655653
assert_snapshot!(markdown_to_html(text, None, ""), @r#"<p align="center"><img src="https://img.shields.io/crates/v/clap.svg" alt=""></p>"#);
656654
}
657655

0 commit comments

Comments
 (0)