Skip to content

Commit ba6feec

Browse files
committed
clippy: Fix new warnings
1 parent 28edd74 commit ba6feec

File tree

10 files changed

+18
-30
lines changed

10 files changed

+18
-30
lines changed

crates/crates_io_markdown/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ impl UrlRelativeEvaluate<'_> for SanitizeUrl {
200200
if let Some(clean) = url.strip_prefix('#') {
201201
// Handle auto-generated footnote links
202202
if clean.starts_with("fn-") || clean.starts_with("fnref-") {
203-
return Some(Cow::Owned(format!("#user-content-{}", clean)));
203+
return Some(Cow::Owned(format!("#user-content-{clean}")));
204204
}
205205

206206
// Always allow fragment URLs.

crates/crates_io_smoke_test/src/api.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ impl ApiClient {
1717
}
1818

1919
pub async fn load_crate<N: Display>(&self, name: N) -> anyhow::Result<CrateResponse> {
20-
let url = format!(
21-
"https://staging.crates.io/api/v1/crates/{}?include=versions",
22-
name
23-
);
20+
let url = format!("https://staging.crates.io/api/v1/crates/{name}?include=versions");
2421

2522
let response = self.http_client.get(url).send().await?;
2623
let response = response.error_for_status()?;
@@ -32,10 +29,7 @@ impl ApiClient {
3229
name: N,
3330
version: V,
3431
) -> anyhow::Result<VersionResponse> {
35-
let url = format!(
36-
"https://staging.crates.io/api/v1/crates/{}/{}",
37-
name, version
38-
);
32+
let url = format!("https://staging.crates.io/api/v1/crates/{name}/{version}");
3933

4034
let response = self.http_client.get(url).send().await?;
4135
let response = response.error_for_status()?;
@@ -47,10 +41,7 @@ impl ApiClient {
4741
name: N,
4842
version: V,
4943
) -> anyhow::Result<Bytes> {
50-
let url = format!(
51-
"https://staging.crates.io/api/v1/crates/{}/{}/download",
52-
name, version
53-
);
44+
let url = format!("https://staging.crates.io/api/v1/crates/{name}/{version}/download");
5445

5546
let response = self.http_client.get(url).send().await?;
5647
let response = response.error_for_status()?;
@@ -62,10 +53,7 @@ impl ApiClient {
6253
name: N,
6354
version: V,
6455
) -> anyhow::Result<Bytes> {
65-
let url = format!(
66-
"https://static.staging.crates.io/crates/{}/{}/download",
67-
name, version
68-
);
56+
let url = format!("https://static.staging.crates.io/crates/{name}/{version}/download");
6957

7058
let response = self.http_client.get(url).send().await?;
7159
let response = response.error_for_status()?;

src/controllers/krate/publish.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ pub async fn publish(app: AppState, req: Parts, body: Body) -> AppResult<Json<Go
579579
if !unknown_categories.is_empty() {
580580
let unknown_categories = unknown_categories.join(", ");
581581
let domain = &app.config.domain_name;
582-
return Err(bad_request(format!("The following category slugs are not currently supported on crates.io: {}\n\nSee https://{}/category_slugs for a list of supported slugs.", unknown_categories, domain)));
582+
return Err(bad_request(format!("The following category slugs are not currently supported on crates.io: {unknown_categories}\n\nSee https://{domain}/category_slugs for a list of supported slugs.")));
583583
}
584584

585585
let top_versions = krate.top_versions(conn).await?;
@@ -734,7 +734,7 @@ async fn read_tarball_bytes<R: AsyncRead + Unpin>(
734734
})?;
735735

736736
if tarball_len > max_length {
737-
let message = format!("max upload size is: {}", max_length);
737+
let message = format!("max upload size is: {max_length}");
738738
return Err(custom(StatusCode::PAYLOAD_TOO_LARGE, message));
739739
}
740740

src/controllers/trustpub/tokens/revoke/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ async fn test_happy_path() -> anyhow::Result<()> {
4848
let _token2 = new_token(&mut conn, 2).await?;
4949
assert_compact_debug_snapshot!(all_crate_ids(&mut conn).await?, @"[[Some(1)], [Some(2)]]");
5050

51-
let header = format!("Bearer {}", token1);
51+
let header = format!("Bearer {token1}");
5252
let token_client = MockTokenUser::with_auth_header(header, app.clone());
5353

5454
let response = token_client.delete::<()>(URL).await;
@@ -129,7 +129,7 @@ async fn test_non_existent_token() -> anyhow::Result<()> {
129129

130130
// Generate a valid token format, but it doesn't exist in the database
131131
let (token, _) = generate_token();
132-
let header = format!("Bearer {}", token);
132+
let header = format!("Bearer {token}");
133133
let token_client = MockTokenUser::with_auth_header(header, app.clone());
134134

135135
// The request should succeed with 204 No Content even though the token doesn't exist

src/email.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static EMAIL_ENV: LazyLock<Environment<'static>> = LazyLock::new(|| {
3737
let subject_contents = std::fs::read_to_string(&subject_path).unwrap_or_else(|error| {
3838
panic!("Failed to read subject template for {email_name}: {error}")
3939
});
40-
let filename = format!("{}/subject.txt.j2", email_name);
40+
let filename = format!("{email_name}/subject.txt.j2");
4141
env.add_template_owned(filename, subject_contents)
4242
.expect("Failed to add subject template");
4343

@@ -46,7 +46,7 @@ static EMAIL_ENV: LazyLock<Environment<'static>> = LazyLock::new(|| {
4646
let body_contents = std::fs::read_to_string(&body_path).unwrap_or_else(|error| {
4747
panic!("Failed to read body template for {email_name}: {error}")
4848
});
49-
let filename = format!("{}/body.txt.j2", email_name);
49+
let filename = format!("{email_name}/body.txt.j2");
5050
env.add_template_owned(filename, body_contents)
5151
.expect("Failed to add body template");
5252
}
@@ -72,8 +72,8 @@ impl EmailMessage {
7272
template_name: &str,
7373
context: impl Serialize,
7474
) -> Result<Self, minijinja::Error> {
75-
let subject = render_template(&format!("{}/subject.txt.j2", template_name), &context)?;
76-
let body_text = render_template(&format!("{}/body.txt.j2", template_name), context)?;
75+
let subject = render_template(&format!("{template_name}/subject.txt.j2"), &context)?;
76+
let body_text = render_template(&format!("{template_name}/body.txt.j2"), context)?;
7777

7878
Ok(EmailMessage { subject, body_text })
7979
}

src/fastly.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl Fastly {
4848
let path = path.trim_start_matches('/');
4949

5050
for domain in domains.iter() {
51-
let url = format!("https://api.fastly.com/purge/{}/{}", domain, path);
51+
let url = format!("https://api.fastly.com/purge/{domain}/{path}");
5252
self.purge_url(&url).await?;
5353
}
5454

src/tests/krate/publish/trustpub.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ async fn test_happy_path_with_fancy_auth_header() -> anyhow::Result<()> {
209209

210210
let token = new_token(&mut conn, krate.id).await?;
211211

212-
let header = format!("beaReR {}", token);
212+
let header = format!("beaReR {token}");
213213
let oidc_token_client = MockTokenUser::with_auth_header(header, app);
214214

215215
let pb = PublishBuilder::new(&krate.name, "1.1.0");

src/tests/routes/crates/versions/list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ async fn page_with_seek<U: RequestHelper>(anon: &U, url: &str) -> (Vec<VersionLi
461461
if let Some(ref new_url) = resp.meta.next_page {
462462
assert!(new_url.contains("seek="));
463463
assert_that!(resp.versions, len(eq(1)));
464-
url = Some(format!("{url_without_query}{}", new_url));
464+
url = Some(format!("{url_without_query}{new_url}"));
465465
assert_ne!(resp.meta.total, 0)
466466
} else {
467467
assert_that!(resp.versions, is_empty());

src/tests/worker/sync_admins.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ async fn create_user(
8888
diesel::insert_into(emails::table)
8989
.values((
9090
emails::user_id.eq(user_id),
91-
emails::email.eq(format!("{}@crates.io", name)),
91+
emails::email.eq(format!("{name}@crates.io")),
9292
emails::verified.eq(true),
9393
))
9494
.execute(conn)

src/worker/jobs/sync_admins.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl BackgroundJob for SyncAdmins {
5858
database_admins
5959
.iter()
6060
.filter(|(gh_id, _, _)| github_ids.contains(gh_id))
61-
.map(|(gh_id, login, _)| format!("{} (github_id: {})", login, gh_id))
61+
.map(|(gh_id, login, _)| format!("{login} (github_id: {gh_id})"))
6262
.collect::<Vec<_>>()
6363
};
6464

0 commit comments

Comments
 (0)