Skip to content

Commit f16efff

Browse files
committed
Run cargo fmt
1 parent 449411f commit f16efff

File tree

19 files changed

+102
-66
lines changed

19 files changed

+102
-66
lines changed

src/bin/cargo/commands/owner.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@ pub fn cli() -> App {
77
.about("Manage the owners of a crate on the registry")
88
.arg(opt("quiet", "No output printed to stdout").short("q"))
99
.arg(Arg::with_name("crate"))
10-
.arg(multi_opt("add", "LOGIN", "Name of a user or team to invite as an owner").short("a"))
10+
.arg(
11+
multi_opt(
12+
"add",
13+
"LOGIN",
14+
"Name of a user or team to invite as an owner",
15+
)
16+
.short("a"),
17+
)
1118
.arg(
1219
multi_opt(
1320
"remove",

src/bin/cargo/commands/test.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ pub fn cli() -> App {
1919
.last(true),
2020
)
2121
.arg(
22-
opt("quiet", "Display one character per test instead of one line")
23-
.short("q")
22+
opt(
23+
"quiet",
24+
"Display one character per test instead of one line",
25+
)
26+
.short("q"),
2427
)
2528
.arg_targets_all(
2629
"Test only this package's library unit tests",
@@ -131,9 +134,9 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
131134
} else if test_name.is_some() {
132135
if let CompileFilter::Default { .. } = compile_opts.filter {
133136
compile_opts.filter = ops::CompileFilter::new(
134-
LibRule::Default, // compile the library, so the unit tests can be run filtered
135-
FilterRule::All, // compile the binaries, so the unit tests in binaries can be run filtered
136-
FilterRule::All, // compile the tests, so the integration tests can be run filtered
137+
LibRule::Default, // compile the library, so the unit tests can be run filtered
138+
FilterRule::All, // compile the binaries, so the unit tests in binaries can be run filtered
139+
FilterRule::All, // compile the tests, so the integration tests can be run filtered
137140
FilterRule::none(), // specify --examples to unit test binaries filtered
138141
FilterRule::none(), // specify --benches to unit test benchmarks filtered
139142
); // also, specify --doc to run doc tests filtered

src/bin/cargo/commands/version.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ use crate::command_prelude::*;
33
use crate::cli;
44

55
pub fn cli() -> App {
6-
subcommand("version").about("Show version information")
6+
subcommand("version")
7+
.about("Show version information")
78
.arg(opt("quiet", "No output printed to stdout").short("q"))
89
}
910

src/cargo/core/compiler/build_context/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,7 @@ impl TargetConfig {
265265
}
266266
"rustc-cdylib-link-arg" => {
267267
let args = value.list(k)?;
268-
output
269-
.linker_args
270-
.extend(args.iter().map(|v| v.0.clone()));
268+
output.linker_args.extend(args.iter().map(|v| v.0.clone()));
271269
}
272270
"rustc-cfg" => {
273271
let list = value.list(k)?;

src/cargo/core/compiler/context/mod.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,10 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
430430
path.display()
431431
)
432432
};
433-
let suggestion = "Consider changing their names to be unique or compiling them separately.\n\
434-
This may become a hard error in the future; see \
435-
<https://github.com/rust-lang/cargo/issues/6313>.";
433+
let suggestion =
434+
"Consider changing their names to be unique or compiling them separately.\n\
435+
This may become a hard error in the future; see \
436+
<https://github.com/rust-lang/cargo/issues/6313>.";
436437
let report_collision = |unit: &Unit<'_>,
437438
other_unit: &Unit<'_>,
438439
path: &PathBuf|

src/cargo/core/compiler/job_queue.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ use crossbeam_utils::thread::Scope;
1111
use jobserver::{Acquired, HelperThread};
1212
use log::{debug, info, trace};
1313

14+
use super::context::OutputFile;
15+
use super::job::Job;
16+
use super::{BuildContext, BuildPlan, CompileMode, Context, Kind, Unit};
1417
use crate::core::profiles::Profile;
1518
use crate::core::{PackageId, Target, TargetKind};
1619
use crate::handle_error;
@@ -19,9 +22,6 @@ use crate::util::diagnostic_server::{self, DiagnosticPrinter};
1922
use crate::util::{internal, profile, CargoResult, CargoResultExt, ProcessBuilder};
2023
use crate::util::{Config, DependencyQueue, Dirty, Fresh, Freshness};
2124
use crate::util::{Progress, ProgressStyle};
22-
use super::context::OutputFile;
23-
use super::job::Job;
24-
use super::{BuildContext, BuildPlan, CompileMode, Context, Kind, Unit};
2525

2626
/// A management structure of the entire dependency graph to compile.
2727
///

src/cargo/core/source/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use std::collections::hash_map::HashMap;
22
use std::fmt;
33

4-
use crate::core::{Dependency, Package, PackageId, Summary};
54
use crate::core::package::PackageSet;
5+
use crate::core::{Dependency, Package, PackageId, Summary};
66
use crate::util::{CargoResult, Config};
77

88
mod source_id;

src/cargo/ops/cargo_compile.rs

+18-8
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,16 @@ impl Packages {
126126
if !opt_out.is_empty() {
127127
ws.config().shell().warn(format!(
128128
"excluded package(s) {} not found in workspace `{}`",
129-
opt_out.iter().map(|x| x.as_ref()).collect::<Vec<_>>().join(", "),
129+
opt_out
130+
.iter()
131+
.map(|x| x.as_ref())
132+
.collect::<Vec<_>>()
133+
.join(", "),
130134
ws.root().display(),
131135
))?;
132136
}
133137
packages
134-
},
138+
}
135139
Packages::Packages(packages) if packages.is_empty() => {
136140
vec![PackageIdSpec::from_package_id(ws.current()?.package_id())]
137141
}
@@ -443,7 +447,11 @@ impl CompileFilter {
443447
all_bens: bool,
444448
all_targets: bool,
445449
) -> CompileFilter {
446-
let rule_lib = if lib_only { LibRule::True } else { LibRule::False };
450+
let rule_lib = if lib_only {
451+
LibRule::True
452+
} else {
453+
LibRule::False
454+
};
447455
let rule_bins = FilterRule::new(bins, all_bins);
448456
let rule_tsts = FilterRule::new(tsts, all_tsts);
449457
let rule_exms = FilterRule::new(exms, all_exms);
@@ -527,11 +535,13 @@ impl CompileFilter {
527535
TargetKind::Test => tests,
528536
TargetKind::Bench => benches,
529537
TargetKind::ExampleBin | TargetKind::ExampleLib(..) => examples,
530-
TargetKind::Lib(..) => return match *lib {
531-
LibRule::True => true,
532-
LibRule::Default => true,
533-
LibRule::False => false,
534-
},
538+
TargetKind::Lib(..) => {
539+
return match *lib {
540+
LibRule::True => true,
541+
LibRule::Default => true,
542+
LibRule::False => false,
543+
};
544+
}
535545
TargetKind::CustomBuild => return false,
536546
};
537547
rule.matches(target)

src/cargo/ops/cargo_package.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -505,10 +505,7 @@ fn hash_all(path: &Path) -> CargoResult<HashMap<PathBuf, u64>> {
505505
Ok(result)
506506
}
507507

508-
fn report_hash_difference(
509-
orig: &HashMap<PathBuf, u64>,
510-
after: &HashMap<PathBuf, u64>,
511-
) -> String {
508+
fn report_hash_difference(orig: &HashMap<PathBuf, u64>, after: &HashMap<PathBuf, u64>) -> String {
512509
let mut changed = Vec::new();
513510
let mut removed = Vec::new();
514511
for (key, value) in orig {

src/cargo/ops/cargo_test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use std::ffi::OsString;
22

33
use crate::core::compiler::{Compilation, Doctest};
4-
use crate::core::Workspace;
54
use crate::core::shell::Verbosity;
5+
use crate::core::Workspace;
66
use crate::ops;
77
use crate::util::errors::CargoResult;
88
use crate::util::{CargoTestError, ProcessError, Test};

src/cargo/sources/git/utils.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,8 @@ where
508508
// callback asking for other authentication methods to try. Check
509509
// cred_helper_bad to make sure we only try the git credentail helper
510510
// once, to avoid looping forever.
511-
if allowed.contains(git2::CredentialType::USER_PASS_PLAINTEXT) && cred_helper_bad.is_none() {
511+
if allowed.contains(git2::CredentialType::USER_PASS_PLAINTEXT) && cred_helper_bad.is_none()
512+
{
512513
let r = git2::Cred::credential_helper(cfg, url, username);
513514
cred_helper_bad = Some(r.is_err());
514515
return r;

src/cargo/sources/replaced.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ impl<'cfg> Source for ReplacedSource<'cfg> {
115115
}
116116

117117
fn add_to_yanked_whitelist(&mut self, pkgs: &[PackageId]) {
118-
let pkgs = pkgs.iter().map(|id| id.with_source_id(self.replace_with))
118+
let pkgs = pkgs
119+
.iter()
120+
.map(|id| id.with_source_id(self.replace_with))
119121
.collect::<Vec<_>>();
120122
self.inner.add_to_yanked_whitelist(&pkgs);
121123
}

tests/testsuite/alt_registry.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,13 @@ Caused by:
620620
.run();
621621

622622
for cmd in &[
623-
"init", "install foo", "login", "owner", "publish", "search", "yank",
623+
"init",
624+
"install foo",
625+
"login",
626+
"owner",
627+
"publish",
628+
"search",
629+
"yank",
624630
] {
625631
p.cargo(cmd)
626632
.arg("--registry")

tests/testsuite/clean.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ fn different_dir() {
2828
p.cargo("build").run();
2929
assert!(p.build_dir().is_dir());
3030

31-
p.cargo("clean")
32-
.cwd("src")
33-
.with_stdout("")
34-
.run();
31+
p.cargo("clean").cwd("src").with_stdout("").run();
3532
assert!(!p.build_dir().is_dir());
3633
}
3734

tests/testsuite/fix.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,10 @@ fn fix_features() {
685685
#[test]
686686
fn shows_warnings() {
687687
let p = project()
688-
.file("src/lib.rs", "#[deprecated] fn bar() {} pub fn foo() { let _ = bar(); }")
688+
.file(
689+
"src/lib.rs",
690+
"#[deprecated] fn bar() {} pub fn foo() { let _ = bar(); }",
691+
)
689692
.build();
690693

691694
p.cargo("fix --allow-no-vcs")

tests/testsuite/package.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ use std::path::Path;
66
use crate::support::cargo_process;
77
use crate::support::registry::Package;
88
use crate::support::{
9-
basic_manifest, git, path2url, paths, project, publish::validate_crate_contents,
10-
registry,
9+
basic_manifest, git, path2url, paths, project, publish::validate_crate_contents, registry,
1110
};
1211
use git2;
1312

@@ -880,9 +879,7 @@ fn ignore_workspace_specifier() {
880879
.file("bar/src/lib.rs", "")
881880
.build();
882881

883-
p.cargo("package --no-verify")
884-
.cwd("bar")
885-
.run();
882+
p.cargo("package --no-verify").cwd("bar").run();
886883

887884
let f = File::open(&p.root().join("target/package/bar-0.1.0.crate")).unwrap();
888885
let rewritten_toml = r#"# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
@@ -1256,7 +1253,9 @@ fn package_with_select_features() {
12561253
)
12571254
.build();
12581255

1259-
p.cargo("package --features required").masquerade_as_nightly_cargo().run();
1256+
p.cargo("package --features required")
1257+
.masquerade_as_nightly_cargo()
1258+
.run();
12601259
}
12611260

12621261
#[test]
@@ -1285,7 +1284,9 @@ fn package_with_all_features() {
12851284
)
12861285
.build();
12871286

1288-
p.cargo("package --all-features").masquerade_as_nightly_cargo().run();
1287+
p.cargo("package --all-features")
1288+
.masquerade_as_nightly_cargo()
1289+
.run();
12891290
}
12901291

12911292
#[test]

tests/testsuite/run.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,10 @@ fn default_run_workspace() {
11101110
.file("b/src/main.rs", r#"fn main() {println!("run-b");}"#)
11111111
.build();
11121112

1113-
p.cargo("run").masquerade_as_nightly_cargo().with_stdout("run-a").run();
1113+
p.cargo("run")
1114+
.masquerade_as_nightly_cargo()
1115+
.with_stdout("run-a")
1116+
.run();
11141117
}
11151118

11161119
#[test]

tests/testsuite/test.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -164,18 +164,20 @@ fn cargo_test_quiet_with_harness() {
164164
fn main() {}
165165
#[test] fn test_hello() {}
166166
"#,
167-
).build();
167+
)
168+
.build();
168169

169-
p.cargo("test -q")
170-
.with_stdout(
171-
"
170+
p.cargo("test -q")
171+
.with_stdout(
172+
"
172173
running 1 test
173174
.
174175
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
175176
176-
"
177-
).with_stderr("")
178-
.run();
177+
",
178+
)
179+
.with_stderr("")
180+
.run();
179181
}
180182

181183
#[test]
@@ -205,13 +207,10 @@ fn cargo_test_quiet_no_harness() {
205207
fn main() {}
206208
#[test] fn test_hello() {}
207209
"#,
208-
).build();
210+
)
211+
.build();
209212

210-
p.cargo("test -q")
211-
.with_stdout(
212-
""
213-
).with_stderr("")
214-
.run();
213+
p.cargo("test -q").with_stdout("").with_stderr("").run();
215214
}
216215

217216
#[test]
@@ -1553,7 +1552,8 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
15531552
15541553
",
15551554
)
1556-
.with_stderr("\
1555+
.with_stderr(
1556+
"\
15571557
[COMPILING] foo v0.0.1 ([CWD])
15581558
[RUNNING] `rustc --crate-name foo src/lib.rs [..] --test [..]`
15591559
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]

tests/testsuite/tool_paths.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,13 @@ fn custom_runner_cfg() {
188188

189189
p.cargo("run -- --param")
190190
.with_status(101)
191-
.with_stderr_contains("\
191+
.with_stderr_contains(
192+
"\
192193
[COMPILING] foo v0.0.1 ([CWD])
193194
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
194195
[RUNNING] `nonexistent-runner -r target/debug/foo[EXE] --param`
195-
")
196+
",
197+
)
196198
.run();
197199
}
198200

@@ -220,11 +222,13 @@ fn custom_runner_cfg_precedence() {
220222

221223
p.cargo("run -- --param")
222224
.with_status(101)
223-
.with_stderr_contains("\
225+
.with_stderr_contains(
226+
"\
224227
[COMPILING] foo v0.0.1 ([CWD])
225228
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
226229
[RUNNING] `nonexistent-runner -r target/debug/foo[EXE] --param`
227-
")
230+
",
231+
)
228232
.run();
229233
}
230234

@@ -246,8 +250,10 @@ fn custom_runner_cfg_collision() {
246250

247251
p.cargo("run -- --param")
248252
.with_status(101)
249-
.with_stderr_contains("\
253+
.with_stderr_contains(
254+
"\
250255
[ERROR] several matching instances of `target.'cfg(..)'.runner` in `.cargo/config`
251-
")
256+
",
257+
)
252258
.run();
253259
}

0 commit comments

Comments
 (0)