Skip to content

Commit 0fa18ac

Browse files
authored
Run cargo fmt and cargo clippy --fix (#781)
This is from cargo 1.88, since 1.89 pulls in let-chains, and whatever version of Rust is in GitHub CI doesn't support them last time I tried. (We should upgrade it at some point, though, since our Rust usage is all internal.)
1 parent ba74729 commit 0fa18ac

File tree

5 files changed

+65
-98
lines changed

5 files changed

+65
-98
lines changed

src/github.rs

Lines changed: 20 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@
44

55
use {
66
crate::release::{
7-
bootstrap_llvm, produce_install_only, produce_install_only_stripped, RELEASE_TRIPLES,
7+
RELEASE_TRIPLES, bootstrap_llvm, produce_install_only, produce_install_only_stripped,
88
},
9-
anyhow::{anyhow, Result},
9+
anyhow::{Result, anyhow},
1010
bytes::Bytes,
1111
clap::ArgMatches,
1212
futures::StreamExt,
1313
octocrab::{
14+
Octocrab, OctocrabBuilder,
1415
models::{repos::Release, workflows::WorkflowListArtifact},
1516
params::actions::ArchiveFormat,
16-
Octocrab, OctocrabBuilder,
1717
},
1818
rayon::prelude::*,
1919
reqwest::{Client, StatusCode},
2020
reqwest_retry::{
21-
default_on_request_failure, policies::ExponentialBackoff, RetryPolicy, Retryable,
22-
RetryableStrategy,
21+
RetryPolicy, Retryable, RetryableStrategy, default_on_request_failure,
22+
policies::ExponentialBackoff,
2323
},
2424
sha2::{Digest, Sha256},
2525
std::{
@@ -70,6 +70,7 @@ enum UploadSource {
7070
Data(Bytes),
7171
}
7272

73+
#[allow(clippy::too_many_arguments)]
7374
async fn upload_release_artifact(
7475
client: &Client,
7576
retry_policy: &impl RetryPolicy,
@@ -286,16 +287,13 @@ pub async fn command_fetch_release_distributions(args: &ArgMatches) -> Result<()
286287
let parts = name.split('-').collect::<Vec<_>>();
287288

288289
if parts[0] != "cpython" {
289-
println!("ignoring {} not a cpython artifact", name);
290+
println!("ignoring {name} not a cpython artifact");
290291
continue;
291292
};
292293

293294
let python_version = pep440_rs::Version::from_str(parts[1])?;
294295
if !release_version_range.contains(&python_version) {
295-
println!(
296-
"{} not in release version range {}",
297-
name, release_version_range
298-
);
296+
println!("{name} not in release version range {release_version_range}");
299297
continue;
300298
}
301299

@@ -310,17 +308,14 @@ pub async fn command_fetch_release_distributions(args: &ArgMatches) -> Result<()
310308
}
311309
})
312310
else {
313-
println!(
314-
"ignoring {} does not match any registered release triples",
315-
name
316-
);
311+
println!("ignoring {name} does not match any registered release triples");
317312
continue;
318313
};
319314

320315
let stripped_name = if let Some(s) = name.strip_suffix(".tar.zst") {
321316
s
322317
} else {
323-
println!("ignoring {} not a .tar.zst artifact", name);
318+
println!("ignoring {name} not a .tar.zst artifact");
324319
continue;
325320
};
326321

@@ -333,7 +328,7 @@ pub async fn command_fetch_release_distributions(args: &ArgMatches) -> Result<()
333328
let build_suffix = &stripped_name[triple_start + triple.len() + 1..];
334329

335330
if !release.suffixes(None).any(|suffix| build_suffix == suffix) {
336-
println!("ignoring {} not a release artifact for triple", name);
331+
println!("ignoring {name} not a release artifact for triple");
337332
continue;
338333
}
339334

@@ -342,7 +337,7 @@ pub async fn command_fetch_release_distributions(args: &ArgMatches) -> Result<()
342337
zf.read_to_end(&mut buf)?;
343338
std::fs::write(&dest_path, &buf)?;
344339

345-
println!("prepared {} for release", name);
340+
println!("prepared {name} for release");
346341

347342
if build_suffix == release.install_only_suffix {
348343
install_paths.push(dest_path);
@@ -452,34 +447,19 @@ pub async fn command_upload_release_distributions(args: &ArgMatches) -> Result<(
452447

453448
for suffix in release.suffixes(Some(&python_version)) {
454449
wanted_filenames.insert(
455-
format!(
456-
"cpython-{}-{}-{}-{}.tar.zst",
457-
version, triple, suffix, datetime
458-
),
459-
format!(
460-
"cpython-{}+{}-{}-{}-full.tar.zst",
461-
version, tag, triple, suffix
462-
),
450+
format!("cpython-{version}-{triple}-{suffix}-{datetime}.tar.zst"),
451+
format!("cpython-{version}+{tag}-{triple}-{suffix}-full.tar.zst"),
463452
);
464453
}
465454

466455
wanted_filenames.insert(
467-
format!(
468-
"cpython-{}-{}-install_only-{}.tar.gz",
469-
version, triple, datetime
470-
),
471-
format!("cpython-{}+{}-{}-install_only.tar.gz", version, tag, triple),
456+
format!("cpython-{version}-{triple}-install_only-{datetime}.tar.gz"),
457+
format!("cpython-{version}+{tag}-{triple}-install_only.tar.gz"),
472458
);
473459

474460
wanted_filenames.insert(
475-
format!(
476-
"cpython-{}-{}-install_only_stripped-{}.tar.gz",
477-
version, triple, datetime
478-
),
479-
format!(
480-
"cpython-{}+{}-{}-install_only_stripped.tar.gz",
481-
version, tag, triple
482-
),
461+
format!("cpython-{version}-{triple}-install_only_stripped-{datetime}.tar.gz"),
462+
format!("cpython-{version}+{tag}-{triple}-install_only_stripped.tar.gz"),
483463
);
484464
}
485465
}
@@ -490,7 +470,7 @@ pub async fn command_upload_release_distributions(args: &ArgMatches) -> Result<(
490470
.collect::<Vec<_>>();
491471

492472
for f in &missing {
493-
println!("missing release artifact: {}", f);
473+
println!("missing release artifact: {f}");
494474
}
495475
if missing.is_empty() {
496476
println!("found all {} release artifacts", wanted_filenames.len());
@@ -564,7 +544,7 @@ pub async fn command_upload_release_distributions(args: &ArgMatches) -> Result<(
564544

565545
let shasums = digests
566546
.iter()
567-
.map(|(filename, digest)| format!("{} {}\n", digest, filename))
547+
.map(|(filename, digest)| format!("{digest} {filename}\n"))
568548
.collect::<Vec<_>>()
569549
.join("");
570550

src/macho.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use {
66
crate::validation::ValidationContext,
7-
anyhow::{anyhow, Context, Result},
7+
anyhow::{Context, Result, anyhow},
88
apple_sdk::{AppleSdk, SdkSearch, SdkSearchLocation, SdkSorting, SdkVersion, SimpleSdk},
99
semver::Version,
1010
std::{
@@ -53,7 +53,7 @@ impl std::fmt::Display for MachOPackedVersion {
5353
let minor = (self.value >> 8) & 0xff;
5454
let subminor = self.value & 0xff;
5555

56-
f.write_str(&format!("{}.{}.{}", major, minor, subminor))
56+
f.write_str(&format!("{major}.{minor}.{subminor}"))
5757
}
5858
}
5959

@@ -128,9 +128,9 @@ impl RequiredSymbols {
128128
fn tbd_relative_path(path: &str) -> Result<String> {
129129
if let Some(stripped) = path.strip_prefix('/') {
130130
if let Some(stem) = stripped.strip_suffix(".dylib") {
131-
Ok(format!("{}.tbd", stem))
131+
Ok(format!("{stem}.tbd"))
132132
} else {
133-
Ok(format!("{}.tbd", stripped))
133+
Ok(format!("{stripped}.tbd"))
134134
}
135135
} else {
136136
Err(anyhow!("could not determine tbd path from {}", path))
@@ -165,13 +165,13 @@ impl TbdMetadata {
165165
export
166166
.objc_classes
167167
.iter()
168-
.map(|cls| format!("_OBJC_CLASS_${}", cls)),
168+
.map(|cls| format!("_OBJC_CLASS_${cls}")),
169169
)
170170
.chain(
171171
export
172172
.objc_classes
173173
.iter()
174-
.map(|cls| format!("_OBJC_METACLASS_${}", cls)),
174+
.map(|cls| format!("_OBJC_METACLASS_${cls}")),
175175
),
176176
);
177177

@@ -214,13 +214,13 @@ impl TbdMetadata {
214214
export
215215
.objc_classes
216216
.iter()
217-
.map(|cls| format!("_OBJC_CLASS_$_{}", cls)),
217+
.map(|cls| format!("_OBJC_CLASS_$_{cls}")),
218218
)
219219
.chain(
220220
export
221221
.objc_classes
222222
.iter()
223-
.map(|cls| format!("_OBJC_METACLASS_$_{}", cls)),
223+
.map(|cls| format!("_OBJC_METACLASS_$_{cls}")),
224224
),
225225
);
226226

@@ -249,13 +249,13 @@ impl TbdMetadata {
249249
export
250250
.objc_classes
251251
.iter()
252-
.map(|cls| format!("_OBJC_CLASS_$_{}", cls)),
252+
.map(|cls| format!("_OBJC_CLASS_$_{cls}")),
253253
)
254254
.chain(
255255
export
256256
.objc_classes
257257
.iter()
258-
.map(|cls| format!("_OBJC_METACLASS_$_{}", cls)),
258+
.map(|cls| format!("_OBJC_METACLASS_$_{cls}")),
259259
),
260260
);
261261
res.weak_symbols
@@ -370,8 +370,7 @@ impl IndexedSdks {
370370
"x86_64-apple-darwin" => "x86_64-macos",
371371
_ => {
372372
context.errors.push(format!(
373-
"unknown target triple for Mach-O symbol analysis: {}",
374-
triple
373+
"unknown target triple for Mach-O symbol analysis: {triple}"
375374
));
376375
return Ok(());
377376
}

src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ mod release;
99
mod validation;
1010

1111
use {
12-
anyhow::{anyhow, Context, Result},
13-
clap::{value_parser, Arg, ArgAction, Command},
12+
anyhow::{Context, Result, anyhow},
13+
clap::{Arg, ArgAction, Command, value_parser},
1414
std::{
1515
io::Read,
1616
path::{Path, PathBuf},
@@ -240,7 +240,7 @@ fn main() {
240240
let exit_code = match main_impl() {
241241
Ok(()) => 0,
242242
Err(err) => {
243-
eprintln!("Error: {:?}", err);
243+
eprintln!("Error: {err:?}");
244244
1
245245
}
246246
};

src/release.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use std::{
1313
use url::Url;
1414
use {
1515
crate::json::parse_python_json,
16-
anyhow::{anyhow, Result},
16+
anyhow::{Result, anyhow},
1717
once_cell::sync::Lazy,
1818
pep440_rs::VersionSpecifier,
1919
std::{
@@ -628,7 +628,7 @@ static LLVM_URL: Lazy<Url> = Lazy::new(|| {
628628
/// Returns the path to the top-level `llvm` directory.
629629
pub async fn bootstrap_llvm() -> Result<PathBuf> {
630630
let url = &*LLVM_URL;
631-
let filename = url.path_segments().unwrap().last().unwrap();
631+
let filename = url.path_segments().unwrap().next_back().unwrap();
632632

633633
let llvm_dir = Path::new("build").join("llvm");
634634
std::fs::create_dir_all(&llvm_dir)?;
@@ -646,7 +646,7 @@ pub async fn bootstrap_llvm() -> Result<PathBuf> {
646646
// Download the tarball.
647647
let tarball_path = temp_dir
648648
.path()
649-
.join(url.path_segments().unwrap().last().unwrap());
649+
.join(url.path_segments().unwrap().next_back().unwrap());
650650
let mut tarball_file = tokio::fs::File::create(&tarball_path).await?;
651651
let mut bytes_stream = reqwest::Client::new()
652652
.get(url.clone())

0 commit comments

Comments
 (0)