Skip to content

Commit aa08c13

Browse files
committed
rustfmt
1 parent 042b2b9 commit aa08c13

File tree

717 files changed

+11142
-33830
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

717 files changed

+11142
-33830
lines changed

benches/benchsuite/benches/global_cache_tracker.rs

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,7 @@ fn initialize_context() -> GlobalContext {
3636
let mut gctx = GlobalContext::new(shell, cwd, homedir);
3737
gctx.nightly_features_allowed = true;
3838
gctx.set_search_stop_path(root());
39-
gctx.configure(
40-
0,
41-
false,
42-
None,
43-
false,
44-
false,
45-
false,
46-
&None,
47-
&["gc".to_string()],
48-
&[],
49-
)
50-
.unwrap();
39+
gctx.configure(0, false, None, false, false, false, &None, &["gc".to_string()], &[]).unwrap();
5140
// Set up database sample.
5241
let db_path = GlobalCacheTracker::db_path(&gctx).into_path_unlocked();
5342
if db_path.exists() {
@@ -62,9 +51,7 @@ fn initialize_context() -> GlobalContext {
6251
/// existing full database.
6352
fn global_tracker_init(c: &mut Criterion) {
6453
let gctx = initialize_context();
65-
let _lock = gctx
66-
.acquire_package_cache_lock(CacheLockMode::DownloadExclusive)
67-
.unwrap();
54+
let _lock = gctx.acquire_package_cache_lock(CacheLockMode::DownloadExclusive).unwrap();
6855
c.bench_function("global_tracker_init", |b| {
6956
b.iter(|| {
7057
GlobalCacheTracker::new(&gctx).unwrap();
@@ -76,9 +63,7 @@ fn global_tracker_init(c: &mut Criterion) {
7663
/// updates.
7764
fn global_tracker_empty_save(c: &mut Criterion) {
7865
let gctx = initialize_context();
79-
let _lock = gctx
80-
.acquire_package_cache_lock(CacheLockMode::DownloadExclusive)
81-
.unwrap();
66+
let _lock = gctx.acquire_package_cache_lock(CacheLockMode::DownloadExclusive).unwrap();
8267
let mut deferred = DeferredGlobalLastUse::new();
8368
let mut tracker = GlobalCacheTracker::new(&gctx).unwrap();
8469

@@ -96,11 +81,7 @@ fn load_random_sample() -> Vec<(InternedString, InternedString, u64)> {
9681
.lines()
9782
.map(|s| {
9883
let mut s = s.split(',');
99-
(
100-
s.next().unwrap().into(),
101-
s.next().unwrap().into(),
102-
s.next().unwrap().parse().unwrap(),
103-
)
84+
(s.next().unwrap().into(), s.next().unwrap().into(), s.next().unwrap().parse().unwrap())
10485
})
10586
.collect()
10687
}
@@ -112,9 +93,7 @@ fn load_random_sample() -> Vec<(InternedString, InternedString, u64)> {
11293
/// from the random sample stored on disk).
11394
fn global_tracker_update(c: &mut Criterion) {
11495
let gctx = initialize_context();
115-
let _lock = gctx
116-
.acquire_package_cache_lock(CacheLockMode::DownloadExclusive)
117-
.unwrap();
96+
let _lock = gctx.acquire_package_cache_lock(CacheLockMode::DownloadExclusive).unwrap();
11897
let sample = Path::new(env!("CARGO_MANIFEST_DIR")).join(GLOBAL_CACHE_SAMPLE);
11998
let db_path = GlobalCacheTracker::db_path(&gctx).into_path_unlocked();
12099

@@ -149,10 +128,5 @@ fn global_tracker_update(c: &mut Criterion) {
149128
}
150129
}
151130

152-
criterion_group!(
153-
benches,
154-
global_tracker_init,
155-
global_tracker_empty_save,
156-
global_tracker_update
157-
);
131+
criterion_group!(benches, global_tracker_init, global_tracker_empty_save, global_tracker_update);
158132
criterion_main!(benches);

benches/benchsuite/benches/resolve.rs

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,8 @@ fn do_resolve<'gctx>(gctx: &'gctx GlobalContext, ws_root: &Path) -> ResolveInfo<
3434
// Do an initial run to download anything necessary so that it does
3535
// not confuse criterion's warmup.
3636
let dry_run = false;
37-
let ws_resolve = cargo::ops::resolve_ws_with_opts(
38-
&ws,
39-
&mut target_data,
40-
&requested_kinds,
41-
&cli_features,
42-
&specs,
43-
has_dev_units,
44-
force_all_targets,
45-
dry_run,
46-
)
47-
.unwrap();
37+
let ws_resolve =
38+
cargo::ops::resolve_ws_with_opts(&ws, &mut target_data, &requested_kinds, &cli_features, &specs, has_dev_units, force_all_targets, dry_run).unwrap();
4839
ResolveInfo {
4940
ws,
5041
requested_kinds,
@@ -86,17 +77,7 @@ fn resolve_ws(c: &mut Criterion) {
8677
..
8778
} = lazy_info.get_or_insert_with(|| do_resolve(&gctx, &ws_root));
8879
b.iter(|| {
89-
cargo::ops::resolve_ws_with_opts(
90-
ws,
91-
target_data,
92-
requested_kinds,
93-
cli_features,
94-
specs,
95-
*has_dev_units,
96-
*force_all_targets,
97-
dry_run,
98-
)
99-
.unwrap();
80+
cargo::ops::resolve_ws_with_opts(ws, target_data, requested_kinds, cli_features, specs, *has_dev_units, *force_all_targets, dry_run).unwrap();
10081
})
10182
});
10283
}

benches/benchsuite/benches/workspace_initialization.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ fn workspace_initialization(c: &mut Criterion) {
1010
// The resolver info is initialized only once in a lazy fashion. This
1111
// allows criterion to skip this workspace if the user passes a filter
1212
// on the command-line (like `cargo bench -- workspace_initialization/tikv`).
13-
group.bench_function(ws_name, |b| {
14-
b.iter(|| Workspace::new(&ws_root.join("Cargo.toml"), &gctx).unwrap())
15-
});
13+
group.bench_function(ws_name, |b| b.iter(|| Workspace::new(&ws_root.join("Cargo.toml"), &gctx).unwrap()));
1614
}
1715
group.finish();
1816
}

benches/benchsuite/src/bin/capture-last-use.rs

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,13 @@ fn main() {
2929
let homedir = Path::new(env!("CARGO_MANIFEST_DIR")).join("global-cache-tracker");
3030
let cwd = homedir.clone();
3131
let mut gctx = GlobalContext::new(shell, cwd, homedir.clone());
32-
gctx.configure(
33-
0,
34-
false,
35-
None,
36-
false,
37-
false,
38-
false,
39-
&None,
40-
&["gc".to_string()],
41-
&[],
42-
)
43-
.unwrap();
32+
gctx.configure(0, false, None, false, false, false, &None, &["gc".to_string()], &[]).unwrap();
4433
let db_path = GlobalCacheTracker::db_path(&gctx).into_path_unlocked();
4534
if db_path.exists() {
4635
fs::remove_file(&db_path).unwrap();
4736
}
4837

49-
let _lock = gctx
50-
.acquire_package_cache_lock(CacheLockMode::DownloadExclusive)
51-
.unwrap();
38+
let _lock = gctx.acquire_package_cache_lock(CacheLockMode::DownloadExclusive).unwrap();
5239
let mut deferred = DeferredGlobalLastUse::new();
5340
let mut tracker = GlobalCacheTracker::new(&gctx).unwrap();
5441

@@ -135,13 +122,6 @@ fn main() {
135122
let sample: Vec<_> = src_entries.choose_multiple(&mut rng, 500).collect();
136123
let mut f = File::create(homedir.join("random-sample")).unwrap();
137124
for src in sample {
138-
writeln!(
139-
f,
140-
"{},{},{}",
141-
src.encoded_registry_name,
142-
src.package_dir,
143-
src.size.unwrap()
144-
)
145-
.unwrap();
125+
writeln!(f, "{},{},{}", src.encoded_registry_name, src.package_dir, src.size.unwrap()).unwrap();
146126
}
147127
}

benches/benchsuite/src/lib.rs

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,7 @@ impl Fixtures {
112112
}
113113
};
114114
if index.exists() {
115-
if maybe_git(&format!(
116-
"rev-parse -q --verify {}^{{commit}}",
117-
CRATES_IO_COMMIT
118-
)) {
115+
if maybe_git(&format!("rev-parse -q --verify {}^{{commit}}", CRATES_IO_COMMIT)) {
119116
// Already fetched.
120117
return;
121118
}
@@ -130,14 +127,8 @@ impl Fixtures {
130127

131128
/// This unpacks the compressed workspace skeletons into tmp/workspaces.
132129
fn unpack_workspaces(&self) {
133-
let ws_dir = Path::new(env!("CARGO_MANIFEST_DIR"))
134-
.parent()
135-
.unwrap()
136-
.join("workspaces");
137-
let archives = fs::read_dir(ws_dir)
138-
.unwrap()
139-
.map(|e| e.unwrap().path())
140-
.filter(|p| p.extension() == Some(std::ffi::OsStr::new("tgz")));
130+
let ws_dir = Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap().join("workspaces");
131+
let archives = fs::read_dir(ws_dir).unwrap().map(|e| e.unwrap().path()).filter(|p| p.extension() == Some(std::ffi::OsStr::new("tgz")));
141132
for archive in archives {
142133
let name = archive.file_stem().unwrap();
143134
let f = fs::File::open(&archive).unwrap();
@@ -170,9 +161,7 @@ impl Fixtures {
170161
};
171162
// Sort so it is consistent.
172163
ps.sort();
173-
ps.into_iter()
174-
.map(|p| (p.file_name().unwrap().to_str().unwrap().to_owned(), p))
175-
.collect()
164+
ps.into_iter().map(|p| (p.file_name().unwrap().to_str().unwrap().to_owned(), p)).collect()
176165
}
177166

178167
/// Creates a new Context.
@@ -181,18 +170,7 @@ impl Fixtures {
181170
let mut gctx = GlobalContext::new(shell, ws_root.to_path_buf(), self.cargo_home());
182171
// Configure is needed to set the target_dir which is needed to write
183172
// the .rustc_info.json file which is very expensive.
184-
gctx.configure(
185-
0,
186-
false,
187-
None,
188-
false,
189-
false,
190-
false,
191-
&Some(self.target_dir()),
192-
&[],
193-
&[],
194-
)
195-
.unwrap();
173+
gctx.configure(0, false, None, false, false, false, &Some(self.target_dir()), &[], &[]).unwrap();
196174
gctx
197175
}
198176
}

benches/capture/src/main.rs

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ use std::process::Command;
1414

1515
fn main() {
1616
let force = std::env::args().any(|arg| arg == "-f");
17-
let dest = Path::new(env!("CARGO_MANIFEST_DIR"))
18-
.parent()
19-
.unwrap()
20-
.join("workspaces");
17+
let dest = Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap().join("workspaces");
2118
if !dest.exists() {
2219
panic!("expected {} to exist", dest.display());
2320
}
@@ -34,18 +31,13 @@ fn capture(source_root: &Path, dest: &Path, force: bool) {
3431
dest_gz.set_extension("tgz");
3532
if dest_gz.exists() {
3633
if !force {
37-
panic!(
38-
"dest {:?} already exists, use -f to force overwriting",
39-
dest_gz
40-
);
34+
panic!("dest {:?} already exists, use -f to force overwriting", dest_gz);
4135
}
4236
fs::remove_file(&dest_gz).unwrap();
4337
}
4438
let vcs_info = capture_vcs_info(source_root, force);
4539
let dst = fs::File::create(&dest_gz).unwrap();
46-
let encoder = GzBuilder::new()
47-
.filename(format!("{}.tar", name.to_str().unwrap()))
48-
.write(dst, Compression::best());
40+
let encoder = GzBuilder::new().filename(format!("{}.tar", name.to_str().unwrap())).write(dst, Compression::best());
4941
let mut ar = tar::Builder::new(encoder);
5042
ar.mode(tar::HeaderMode::Deterministic);
5143
if let Some(info) = &vcs_info {
@@ -80,17 +72,8 @@ fn capture(source_root: &Path, dest: &Path, force: bool) {
8072
eprintln!("created {}", dest_gz.display());
8173
}
8274

83-
fn copy_manifest<W: std::io::Write>(
84-
manifest_path: &Path,
85-
ar: &mut tar::Builder<W>,
86-
name: &Path,
87-
source_root: &Path,
88-
) {
89-
let relative_path = manifest_path
90-
.parent()
91-
.unwrap()
92-
.strip_prefix(source_root)
93-
.expect("workspace member should be under workspace root");
75+
fn copy_manifest<W: std::io::Write>(manifest_path: &Path, ar: &mut tar::Builder<W>, name: &Path, source_root: &Path) {
76+
let relative_path = manifest_path.parent().unwrap().strip_prefix(source_root).expect("workspace member should be under workspace root");
9477
let relative_path = name.join(relative_path);
9578
let contents = fs::read_to_string(&manifest_path).unwrap();
9679
let mut manifest: toml::Value = toml::from_str(&contents).unwrap();
@@ -121,8 +104,7 @@ fn add_ar_file<W: std::io::Write>(ar: &mut tar::Builder<W>, path: &Path, content
121104
header.set_size(contents.len() as u64);
122105
header.set_mtime(123456789);
123106
header.set_cksum();
124-
ar.append_data(&mut header, path, contents.as_bytes())
125-
.unwrap();
107+
ar.append_data(&mut header, path, contents.as_bytes()).unwrap();
126108
}
127109

128110
fn capture_vcs_info(ws_root: &Path, force: bool) -> Option<String> {

build.rs

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,19 @@ fn compress_man() {
1919
#[allow(clippy::disallowed_methods)]
2020
let out_path = Path::new(&std::env::var("OUT_DIR").unwrap()).join("man.tgz");
2121
let dst = fs::File::create(out_path).unwrap();
22-
let encoder = GzBuilder::new()
23-
.filename("man.tar")
24-
.write(dst, Compression::best());
22+
let encoder = GzBuilder::new().filename("man.tar").write(dst, Compression::best());
2523
let mut ar = tar::Builder::new(encoder);
2624
ar.mode(tar::HeaderMode::Deterministic);
2725

2826
let mut add_files = |dir, extension| {
29-
let mut files = fs::read_dir(dir)
30-
.unwrap()
31-
.map(|e| e.unwrap().path())
32-
.collect::<Vec<_>>();
27+
let mut files = fs::read_dir(dir).unwrap().map(|e| e.unwrap().path()).collect::<Vec<_>>();
3328
files.sort();
3429
for path in files {
3530
if path.extension() != Some(extension) {
3631
continue;
3732
}
3833
println!("cargo:rerun-if-changed={}", path.display());
39-
ar.append_path_with_name(&path, path.file_name().unwrap())
40-
.unwrap();
34+
ar.append_path_with_name(&path, path.file_name().unwrap()).unwrap();
4135
}
4236
};
4337

@@ -58,14 +52,7 @@ fn commit_info_from_git() -> Option<CommitInfo> {
5852
return None;
5953
}
6054

61-
let output = match Command::new("git")
62-
.arg("log")
63-
.arg("-1")
64-
.arg("--date=short")
65-
.arg("--format=%H %h %cd")
66-
.arg("--abbrev=9")
67-
.output()
68-
{
55+
let output = match Command::new("git").arg("log").arg("-1").arg("--date=short").arg("--format=%H %h %cd").arg("--abbrev=9").output() {
6956
Ok(output) if output.status.success() => output,
7057
_ => return None,
7158
};
@@ -143,10 +130,7 @@ fn windows_manifest() {
143130
println!("cargo:rerun-if-changed={WINDOWS_MANIFEST_FILE}");
144131
// Embed the Windows application manifest file.
145132
println!("cargo:rustc-link-arg-bin=cargo=/MANIFEST:EMBED");
146-
println!(
147-
"cargo:rustc-link-arg-bin=cargo=/MANIFESTINPUT:{}",
148-
manifest.to_str().unwrap()
149-
);
133+
println!("cargo:rustc-link-arg-bin=cargo=/MANIFESTINPUT:{}", manifest.to_str().unwrap());
150134
// Turn linker warnings into errors.
151135
println!("cargo:rustc-link-arg-bin=cargo=/WX");
152136
}

crates/cargo-platform/examples/matches.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@ fn main() {
3131
}
3232

3333
fn get_target() -> String {
34-
let output = Command::new("rustc")
35-
.arg("-Vv")
36-
.output()
37-
.expect("rustc failed to run");
34+
let output = Command::new("rustc").arg("-Vv").output().expect("rustc failed to run");
3835
let stdout = String::from_utf8(output.stdout).unwrap();
3936
for line in stdout.lines() {
4037
if let Some(line) = line.strip_prefix("host: ") {
@@ -45,13 +42,7 @@ fn get_target() -> String {
4542
}
4643

4744
fn get_cfgs() -> Vec<Cfg> {
48-
let output = Command::new("rustc")
49-
.arg("--print=cfg")
50-
.output()
51-
.expect("rustc failed to run");
45+
let output = Command::new("rustc").arg("--print=cfg").output().expect("rustc failed to run");
5246
let stdout = String::from_utf8(output.stdout).unwrap();
53-
stdout
54-
.lines()
55-
.map(|line| Cfg::from_str(line).unwrap())
56-
.collect()
47+
stdout.lines().map(|line| Cfg::from_str(line).unwrap()).collect()
5748
}

0 commit comments

Comments
 (0)