Skip to content

Commit 97e3ad7

Browse files
committed
fix clippy warnings
1 parent 2861a10 commit 97e3ad7

32 files changed

+143
-188
lines changed

build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ fn write_git_version(out_dir: &Path) -> Result<()> {
9191

9292
std::fs::write(
9393
out_dir.join("git_version"),
94-
format!("({} {})", git_hash, build_date),
94+
format!("({git_hash} {build_date})"),
9595
)?;
9696

9797
Ok(())

crates/font-awesome-as-a-crate/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ fn write_fontawesome_sprite() {
3030
file.read_to_string(&mut data)
3131
.expect("fontawesome file read");
3232
// if this assert goes off, add more hashes here and in the format! below
33-
assert!(!data.contains("###"), "file {} breaks raw string", filename);
33+
assert!(!data.contains("###"), "file {filename} breaks raw string");
3434
dest_file
3535
.write_all(
3636
format!(

crates/metadata/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,18 +280,18 @@ impl Metadata {
280280
cargo_args.push("--config".into());
281281
let rustflags =
282282
toml::to_string(&self.rustc_args).expect("serializing a string should never fail");
283-
cargo_args.push(format!("build.rustflags={}", rustflags));
283+
cargo_args.push(format!("build.rustflags={rustflags}"));
284284
cargo_args.push("-Zhost-config".into());
285285
cargo_args.push("-Ztarget-applies-to-host".into());
286286
cargo_args.push("--config".into());
287-
cargo_args.push(format!("host.rustflags={}", rustflags));
287+
cargo_args.push(format!("host.rustflags={rustflags}"));
288288
}
289289

290290
if !all_rustdoc_args.is_empty() {
291291
cargo_args.push("--config".into());
292292
let rustdocflags =
293293
toml::to_string(&all_rustdoc_args).expect("serializing a string should never fail");
294-
cargo_args.push(format!("build.rustdocflags={}", rustdocflags));
294+
cargo_args.push(format!("build.rustdocflags={rustdocflags}"));
295295
}
296296

297297
cargo_args.extend(additional_args.iter().map(|s| s.to_owned()));
@@ -645,7 +645,7 @@ mod test_targets {
645645
other_targets: others,
646646
..
647647
} = metadata.targets(false);
648-
assert!(others.is_empty(), "{:?}", others);
648+
assert!(others.is_empty(), "{others:?}");
649649
}
650650
}
651651

src/bin/cratesfyi.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ fn main() {
5252
};
5353

5454
if let Err(err) = CommandLine::parse().handle_args() {
55-
let mut msg = format!("Error: {}", err);
55+
let mut msg = format!("Error: {err}");
5656
for cause in err.chain() {
57-
write!(msg, "\n\nCaused by:\n {}", cause).unwrap();
57+
write!(msg, "\n\nCaused by:\n {cause}").unwrap();
5858
}
59-
eprintln!("{}", msg);
59+
eprintln!("{msg}");
6060

6161
let backtrace = err.backtrace().to_string();
6262
if !backtrace.is_empty() {
63-
eprintln!("\nStack backtrace:\n{}", backtrace);
63+
eprintln!("\nStack backtrace:\n{backtrace}");
6464
}
6565

6666
// we need to drop the sentry guard here so all unsent
@@ -254,7 +254,7 @@ impl PrioritySubcommand {
254254
if let Some(priority) = remove_crate_priority(&mut *ctx.conn()?, &pattern)
255255
.context("Could not remove pattern's priority")?
256256
{
257-
println!("Removed pattern with priority {}", priority);
257+
println!("Removed pattern with priority {priority}");
258258
} else {
259259
println!("Pattern did not exist and so was not removed");
260260
}

src/build_queue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ impl BuildQueue {
300300
for change in &changes {
301301
if let Some((ref krate, ..)) = change.deleted() {
302302
match delete_crate(&mut conn, &self.storage, &self.config, krate)
303-
.with_context(|| format!("failed to delete crate {}", krate))
303+
.with_context(|| format!("failed to delete crate {krate}"))
304304
{
305305
Ok(_) => info!(
306306
"crate {} was deleted from the index and the database",

src/cdn.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,12 +415,12 @@ pub(crate) fn queue_crate_invalidation(
415415
if let Some(distribution_id) = config.cloudfront_distribution_id_web.as_ref() {
416416
add(
417417
distribution_id,
418-
&[&format!("/{}*", name), &format!("/crate/{}*", name)],
418+
&[&format!("/{name}*"), &format!("/crate/{name}*")],
419419
)
420420
.context("error enqueueing web CDN invalidation")?;
421421
}
422422
if let Some(distribution_id) = config.cloudfront_distribution_id_static.as_ref() {
423-
add(distribution_id, &[&format!("/rustdoc/{}*", name)])
423+
add(distribution_id, &[&format!("/rustdoc/{name}*")])
424424
.context("error enqueueing static CDN invalidation")?;
425425
}
426426

src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ where
209209
Ok(content) => Ok(content
210210
.parse::<T>()
211211
.map(Some)
212-
.with_context(|| format!("failed to parse configuration variable {}", var))?),
212+
.with_context(|| format!("failed to parse configuration variable {var}"))?),
213213
Err(VarError::NotPresent) => {
214214
trace!("optional configuration variable {} is not set", var);
215215
Ok(None)

src/db/add_package.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -669,8 +669,8 @@ mod test {
669669

670670
let new_owners: Vec<CrateOwner> = (1..5)
671671
.map(|i| CrateOwner {
672-
login: format!("login{}", i),
673-
avatar: format!("avatar{}", i),
672+
login: format!("login{i}"),
673+
avatar: format!("avatar{i}"),
674674
})
675675
.collect();
676676

src/db/delete.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub fn delete_crate(
3636
for prefix in paths {
3737
// delete the whole rustdoc/source folder for this crate.
3838
// it will include existing archives.
39-
let remote_folder = format!("{}/{}/", prefix, name);
39+
let remote_folder = format!("{prefix}/{name}/");
4040
storage.delete_prefix(&remote_folder)?;
4141

4242
// remove existing local archive index files.
@@ -67,7 +67,7 @@ pub fn delete_version(ctx: &dyn Context, name: &str, version: &str) -> Result<()
6767
};
6868

6969
for prefix in paths {
70-
storage.delete_prefix(&format!("{}/{}/{}/", prefix, name, version))?;
70+
storage.delete_prefix(&format!("{prefix}/{name}/{version}/"))?;
7171
}
7272

7373
let local_archive_cache = &ctx.config()?.local_archive_cache_path;
@@ -81,13 +81,10 @@ pub fn delete_version(ctx: &dyn Context, name: &str, version: &str) -> Result<()
8181
storage.delete_prefix(&archive_filename)?;
8282

8383
// delete eventually existing local indexes
84-
let local_index_file = local_archive_cache.join(format!("{}.index", archive_filename));
84+
let local_index_file = local_archive_cache.join(format!("{archive_filename}.index"));
8585
if local_index_file.exists() {
8686
fs::remove_file(&local_index_file).with_context(|| {
87-
format!(
88-
"error when trying to remove local index: {:?}",
89-
local_index_file
90-
)
87+
format!("error when trying to remove local index: {local_index_file:?}")
9188
})?;
9289
}
9390
}
@@ -119,7 +116,7 @@ fn delete_version_from_database(conn: &mut Client, name: &str, version: &str) ->
119116
let mut transaction = conn.transaction()?;
120117
for &(table, column) in METADATA {
121118
transaction.execute(
122-
format!("DELETE FROM {} WHERE {} IN (SELECT id FROM releases WHERE crate_id = $1 AND version = $2)", table, column).as_str(),
119+
format!("DELETE FROM {table} WHERE {column} IN (SELECT id FROM releases WHERE crate_id = $1 AND version = $2)").as_str(),
123120
&[&crate_id, &version],
124121
)?;
125122
}
@@ -146,7 +143,7 @@ fn delete_version_from_database(conn: &mut Client, name: &str, version: &str) ->
146143
for prefix in paths {
147144
transaction.execute(
148145
"DELETE FROM files WHERE path LIKE $1;",
149-
&[&format!("{}/{}/{}/%", prefix, name, version)],
146+
&[&format!("{prefix}/{name}/{version}/%")],
150147
)?;
151148
}
152149

@@ -165,8 +162,7 @@ fn delete_crate_from_database(conn: &mut Client, name: &str, crate_id: i32) -> R
165162
for &(table, column) in METADATA {
166163
transaction.execute(
167164
format!(
168-
"DELETE FROM {} WHERE {} IN (SELECT id FROM releases WHERE crate_id = $1)",
169-
table, column
165+
"DELETE FROM {table} WHERE {column} IN (SELECT id FROM releases WHERE crate_id = $1)"
170166
)
171167
.as_str(),
172168
&[&crate_id],
@@ -246,7 +242,7 @@ mod tests {
246242
assert!(env.storage().rustdoc_file_exists(
247243
pkg,
248244
version,
249-
&format!("{}/index.html", pkg),
245+
&format!("{pkg}/index.html"),
250246
archive_storage
251247
)?);
252248
}
@@ -372,7 +368,7 @@ mod tests {
372368
assert!(!env.storage().exists(&rustdoc_archive)?);
373369

374370
// local and remote index are gone too
375-
let archive_index = format!("{}.index", rustdoc_archive);
371+
let archive_index = format!("{rustdoc_archive}.index");
376372
assert!(!env.storage().exists(&archive_index)?);
377373
assert!(!env
378374
.config()

src/docbuilder/rustwide_builder.rs

Lines changed: 24 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ impl RustwideBuilder {
230230

231231
let mut build_dir = self
232232
.workspace
233-
.build_dir(&format!("essential-files-{}", rustc_version));
233+
.build_dir(&format!("essential-files-{rustc_version}"));
234234
build_dir.purge().map_err(FailureError::compat)?;
235235

236236
// This is an empty library crate that is supposed to always build.
@@ -361,7 +361,7 @@ impl RustwideBuilder {
361361
}
362362
}
363363

364-
let mut build_dir = self.workspace.build_dir(&format!("{}-{}", name, version));
364+
let mut build_dir = self.workspace.build_dir(&format!("{name}-{version}"));
365365
build_dir.purge().map_err(FailureError::compat)?;
366366

367367
let krate = match kind {
@@ -490,7 +490,7 @@ impl RustwideBuilder {
490490
.api()
491491
.get_release_data(name, version)
492492
.with_context(|| {
493-
format!("could not fetch releases-data for {}-{}", name, version)
493+
format!("could not fetch releases-data for {name}-{version}")
494494
}) {
495495
Ok(data) => data,
496496
Err(err) => {
@@ -523,7 +523,7 @@ impl RustwideBuilder {
523523
}
524524

525525
let build_id = add_build_into_database(&mut conn, release_id, &res.result)?;
526-
let build_log_path = format!("build-logs/{}/{}.txt", build_id, default_target);
526+
let build_log_path = format!("build-logs/{build_id}/{default_target}.txt");
527527
self.storage.store_one(build_log_path, res.build_log)?;
528528

529529
// Some crates.io crate data is mutable, so we proactively update it during a release
@@ -539,7 +539,7 @@ impl RustwideBuilder {
539539
// we're doing this in the end so eventual problems in the build
540540
// won't lead to non-existing docs.
541541
for prefix in &["rustdoc", "sources"] {
542-
let prefix = format!("{}/{}/{}/", prefix, name, version);
542+
let prefix = format!("{prefix}/{name}/{version}/");
543543
debug!("cleaning old storage folder {}", prefix);
544544
self.storage.delete_prefix(&prefix)?;
545545
}
@@ -741,15 +741,14 @@ impl RustwideBuilder {
741741
//
742742
// FIXME: host-only crates like proc-macros should probably not have this passed? but #1417 should make it OK
743743
format!(
744-
r#"--config=doc.extern-map.registries.crates-io="https://docs.rs/{{pkg_name}}/{{version}}/{}""#,
745-
target
744+
r#"--config=doc.extern-map.registries.crates-io="https://docs.rs/{{pkg_name}}/{{version}}/{target}""#
746745
),
747746
// Enables the unstable rustdoc-scrape-examples feature. We are "soft launching" this feature on
748747
// docs.rs, but once it's stable we can remove this flag.
749748
"-Zrustdoc-scrape-examples".into(),
750749
];
751750
if let Some(cpu_limit) = self.config.build_cpu_limit {
752-
cargo_args.push(format!("-j{}", cpu_limit));
751+
cargo_args.push(format!("-j{cpu_limit}"));
753752
}
754753
// Cargo has a series of frightening bugs around cross-compiling proc-macros:
755754
// - Passing `--target` causes RUSTDOCFLAGS to fail to be passed 🤦
@@ -879,8 +878,8 @@ mod tests {
879878
let default_target = "x86_64-unknown-linux-gnu";
880879

881880
let storage = env.storage();
882-
let old_rustdoc_file = format!("rustdoc/{}/{}/some_doc_file", crate_, version);
883-
let old_source_file = format!("sources/{}/{}/some_source_file", crate_, version);
881+
let old_rustdoc_file = format!("rustdoc/{crate_}/{version}/some_doc_file");
882+
let old_source_file = format!("sources/{crate_}/{version}/some_source_file");
884883
storage.store_one(&old_rustdoc_file, Vec::new())?;
885884
storage.store_one(&old_source_file, Vec::new())?;
886885

@@ -938,28 +937,23 @@ mod tests {
938937
assert!(storage.exists(&source_archive)?, "{}", source_archive);
939938

940939
// default target was built and is accessible
941-
assert!(storage.exists_in_archive(&doc_archive, &format!("{}/index.html", crate_path))?);
942-
assert_success(&format!("/{}/{}/{}", crate_, version, crate_path), web)?;
940+
assert!(storage.exists_in_archive(&doc_archive, &format!("{crate_path}/index.html"))?);
941+
assert_success(&format!("/{crate_}/{version}/{crate_path}"), web)?;
943942

944943
// source is also packaged
945944
assert!(storage.exists_in_archive(&source_archive, "src/lib.rs")?);
946-
assert_success(
947-
&format!("/crate/{}/{}/source/src/lib.rs", crate_, version),
948-
web,
949-
)?;
945+
assert_success(&format!("/crate/{crate_}/{version}/source/src/lib.rs"), web)?;
950946

951947
assert!(!storage.exists_in_archive(
952948
&doc_archive,
953-
&format!("{}/{}/index.html", default_target, crate_path),
949+
&format!("{default_target}/{crate_path}/index.html"),
954950
)?);
955951

956-
let default_target_url = format!(
957-
"/{}/{}/{}/{}/index.html",
958-
crate_, version, default_target, crate_path
959-
);
952+
let default_target_url =
953+
format!("/{crate_}/{version}/{default_target}/{crate_path}/index.html");
960954
assert_redirect(
961955
&default_target_url,
962-
&format!("/{}/{}/{}/index.html", crate_, version, crate_path),
956+
&format!("/{crate_}/{version}/{crate_path}/index.html"),
963957
web,
964958
)?;
965959

@@ -985,13 +979,11 @@ mod tests {
985979
}
986980
let target_docs_present = storage.exists_in_archive(
987981
&doc_archive,
988-
&format!("{}/{}/index.html", target, crate_path),
982+
&format!("{target}/{crate_path}/index.html"),
989983
)?;
990984

991-
let target_url = format!(
992-
"/{}/{}/{}/{}/index.html",
993-
crate_, version, target, crate_path
994-
);
985+
let target_url =
986+
format!("/{crate_}/{version}/{target}/{crate_path}/index.html");
995987

996988
assert!(target_docs_present);
997989
assert_success(&target_url, web)?;
@@ -1011,8 +1003,8 @@ mod tests {
10111003
let version = "0.2.3";
10121004

10131005
let storage = env.storage();
1014-
let old_rustdoc_file = format!("rustdoc/{}/{}/some_doc_file", crate_, version);
1015-
let old_source_file = format!("sources/{}/{}/some_source_file", crate_, version);
1006+
let old_rustdoc_file = format!("rustdoc/{crate_}/{version}/some_doc_file");
1007+
let old_source_file = format!("sources/{crate_}/{version}/some_source_file");
10161008
storage.store_one(&old_rustdoc_file, Vec::new())?;
10171009
storage.store_one(&old_source_file, Vec::new())?;
10181010

@@ -1104,16 +1096,11 @@ mod tests {
11041096

11051097
let target = "x86_64-unknown-linux-gnu";
11061098
let crate_path = crate_.replace('-', "_");
1107-
let target_docs_present = storage.exists_in_archive(
1108-
&doc_archive,
1109-
&format!("{}/{}/index.html", target, crate_path),
1110-
)?;
1099+
let target_docs_present = storage
1100+
.exists_in_archive(&doc_archive, &format!("{target}/{crate_path}/index.html"))?;
11111101

11121102
let web = env.frontend();
1113-
let target_url = format!(
1114-
"/{}/{}/{}/{}/index.html",
1115-
crate_, version, target, crate_path
1116-
);
1103+
let target_url = format!("/{crate_}/{version}/{target}/{crate_path}/index.html");
11171104

11181105
assert!(target_docs_present);
11191106
assert_success(&target_url, web)?;

0 commit comments

Comments
 (0)