Skip to content

Commit

Permalink
Run cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Apr 10, 2019
1 parent 449411f commit f16efff
Show file tree
Hide file tree
Showing 19 changed files with 102 additions and 66 deletions.
9 changes: 8 additions & 1 deletion src/bin/cargo/commands/owner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ pub fn cli() -> App {
.about("Manage the owners of a crate on the registry")
.arg(opt("quiet", "No output printed to stdout").short("q"))
.arg(Arg::with_name("crate"))
.arg(multi_opt("add", "LOGIN", "Name of a user or team to invite as an owner").short("a"))
.arg(
multi_opt(
"add",
"LOGIN",
"Name of a user or team to invite as an owner",
)
.short("a"),
)
.arg(
multi_opt(
"remove",
Expand Down
13 changes: 8 additions & 5 deletions src/bin/cargo/commands/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ pub fn cli() -> App {
.last(true),
)
.arg(
opt("quiet", "Display one character per test instead of one line")
.short("q")
opt(
"quiet",
"Display one character per test instead of one line",
)
.short("q"),
)
.arg_targets_all(
"Test only this package's library unit tests",
Expand Down Expand Up @@ -131,9 +134,9 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
} else if test_name.is_some() {
if let CompileFilter::Default { .. } = compile_opts.filter {
compile_opts.filter = ops::CompileFilter::new(
LibRule::Default, // compile the library, so the unit tests can be run filtered
FilterRule::All, // compile the binaries, so the unit tests in binaries can be run filtered
FilterRule::All, // compile the tests, so the integration tests can be run filtered
LibRule::Default, // compile the library, so the unit tests can be run filtered
FilterRule::All, // compile the binaries, so the unit tests in binaries can be run filtered
FilterRule::All, // compile the tests, so the integration tests can be run filtered
FilterRule::none(), // specify --examples to unit test binaries filtered
FilterRule::none(), // specify --benches to unit test benchmarks filtered
); // also, specify --doc to run doc tests filtered
Expand Down
3 changes: 2 additions & 1 deletion src/bin/cargo/commands/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ use crate::command_prelude::*;
use crate::cli;

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

Expand Down
4 changes: 1 addition & 3 deletions src/cargo/core/compiler/build_context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,7 @@ impl TargetConfig {
}
"rustc-cdylib-link-arg" => {
let args = value.list(k)?;
output
.linker_args
.extend(args.iter().map(|v| v.0.clone()));
output.linker_args.extend(args.iter().map(|v| v.0.clone()));
}
"rustc-cfg" => {
let list = value.list(k)?;
Expand Down
7 changes: 4 additions & 3 deletions src/cargo/core/compiler/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,10 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
path.display()
)
};
let suggestion = "Consider changing their names to be unique or compiling them separately.\n\
This may become a hard error in the future; see \
<https://github.com/rust-lang/cargo/issues/6313>.";
let suggestion =
"Consider changing their names to be unique or compiling them separately.\n\
This may become a hard error in the future; see \
<https://github.com/rust-lang/cargo/issues/6313>.";
let report_collision = |unit: &Unit<'_>,
other_unit: &Unit<'_>,
path: &PathBuf|
Expand Down
6 changes: 3 additions & 3 deletions src/cargo/core/compiler/job_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ use crossbeam_utils::thread::Scope;
use jobserver::{Acquired, HelperThread};
use log::{debug, info, trace};

use super::context::OutputFile;
use super::job::Job;
use super::{BuildContext, BuildPlan, CompileMode, Context, Kind, Unit};
use crate::core::profiles::Profile;
use crate::core::{PackageId, Target, TargetKind};
use crate::handle_error;
Expand All @@ -19,9 +22,6 @@ use crate::util::diagnostic_server::{self, DiagnosticPrinter};
use crate::util::{internal, profile, CargoResult, CargoResultExt, ProcessBuilder};
use crate::util::{Config, DependencyQueue, Dirty, Fresh, Freshness};
use crate::util::{Progress, ProgressStyle};
use super::context::OutputFile;
use super::job::Job;
use super::{BuildContext, BuildPlan, CompileMode, Context, Kind, Unit};

/// A management structure of the entire dependency graph to compile.
///
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/core/source/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::collections::hash_map::HashMap;
use std::fmt;

use crate::core::{Dependency, Package, PackageId, Summary};
use crate::core::package::PackageSet;
use crate::core::{Dependency, Package, PackageId, Summary};
use crate::util::{CargoResult, Config};

mod source_id;
Expand Down
26 changes: 18 additions & 8 deletions src/cargo/ops/cargo_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,16 @@ impl Packages {
if !opt_out.is_empty() {
ws.config().shell().warn(format!(
"excluded package(s) {} not found in workspace `{}`",
opt_out.iter().map(|x| x.as_ref()).collect::<Vec<_>>().join(", "),
opt_out
.iter()
.map(|x| x.as_ref())
.collect::<Vec<_>>()
.join(", "),
ws.root().display(),
))?;
}
packages
},
}
Packages::Packages(packages) if packages.is_empty() => {
vec![PackageIdSpec::from_package_id(ws.current()?.package_id())]
}
Expand Down Expand Up @@ -443,7 +447,11 @@ impl CompileFilter {
all_bens: bool,
all_targets: bool,
) -> CompileFilter {
let rule_lib = if lib_only { LibRule::True } else { LibRule::False };
let rule_lib = if lib_only {
LibRule::True
} else {
LibRule::False
};
let rule_bins = FilterRule::new(bins, all_bins);
let rule_tsts = FilterRule::new(tsts, all_tsts);
let rule_exms = FilterRule::new(exms, all_exms);
Expand Down Expand Up @@ -527,11 +535,13 @@ impl CompileFilter {
TargetKind::Test => tests,
TargetKind::Bench => benches,
TargetKind::ExampleBin | TargetKind::ExampleLib(..) => examples,
TargetKind::Lib(..) => return match *lib {
LibRule::True => true,
LibRule::Default => true,
LibRule::False => false,
},
TargetKind::Lib(..) => {
return match *lib {
LibRule::True => true,
LibRule::Default => true,
LibRule::False => false,
};
}
TargetKind::CustomBuild => return false,
};
rule.matches(target)
Expand Down
5 changes: 1 addition & 4 deletions src/cargo/ops/cargo_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,10 +505,7 @@ fn hash_all(path: &Path) -> CargoResult<HashMap<PathBuf, u64>> {
Ok(result)
}

fn report_hash_difference(
orig: &HashMap<PathBuf, u64>,
after: &HashMap<PathBuf, u64>,
) -> String {
fn report_hash_difference(orig: &HashMap<PathBuf, u64>, after: &HashMap<PathBuf, u64>) -> String {
let mut changed = Vec::new();
let mut removed = Vec::new();
for (key, value) in orig {
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/ops/cargo_test.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::ffi::OsString;

use crate::core::compiler::{Compilation, Doctest};
use crate::core::Workspace;
use crate::core::shell::Verbosity;
use crate::core::Workspace;
use crate::ops;
use crate::util::errors::CargoResult;
use crate::util::{CargoTestError, ProcessError, Test};
Expand Down
3 changes: 2 additions & 1 deletion src/cargo/sources/git/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,8 @@ where
// callback asking for other authentication methods to try. Check
// cred_helper_bad to make sure we only try the git credentail helper
// once, to avoid looping forever.
if allowed.contains(git2::CredentialType::USER_PASS_PLAINTEXT) && cred_helper_bad.is_none() {
if allowed.contains(git2::CredentialType::USER_PASS_PLAINTEXT) && cred_helper_bad.is_none()
{
let r = git2::Cred::credential_helper(cfg, url, username);
cred_helper_bad = Some(r.is_err());
return r;
Expand Down
4 changes: 3 additions & 1 deletion src/cargo/sources/replaced.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ impl<'cfg> Source for ReplacedSource<'cfg> {
}

fn add_to_yanked_whitelist(&mut self, pkgs: &[PackageId]) {
let pkgs = pkgs.iter().map(|id| id.with_source_id(self.replace_with))
let pkgs = pkgs
.iter()
.map(|id| id.with_source_id(self.replace_with))
.collect::<Vec<_>>();
self.inner.add_to_yanked_whitelist(&pkgs);
}
Expand Down
8 changes: 7 additions & 1 deletion tests/testsuite/alt_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,13 @@ Caused by:
.run();

for cmd in &[
"init", "install foo", "login", "owner", "publish", "search", "yank",
"init",
"install foo",
"login",
"owner",
"publish",
"search",
"yank",
] {
p.cargo(cmd)
.arg("--registry")
Expand Down
5 changes: 1 addition & 4 deletions tests/testsuite/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ fn different_dir() {
p.cargo("build").run();
assert!(p.build_dir().is_dir());

p.cargo("clean")
.cwd("src")
.with_stdout("")
.run();
p.cargo("clean").cwd("src").with_stdout("").run();
assert!(!p.build_dir().is_dir());
}

Expand Down
5 changes: 4 additions & 1 deletion tests/testsuite/fix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,10 @@ fn fix_features() {
#[test]
fn shows_warnings() {
let p = project()
.file("src/lib.rs", "#[deprecated] fn bar() {} pub fn foo() { let _ = bar(); }")
.file(
"src/lib.rs",
"#[deprecated] fn bar() {} pub fn foo() { let _ = bar(); }",
)
.build();

p.cargo("fix --allow-no-vcs")
Expand Down
15 changes: 8 additions & 7 deletions tests/testsuite/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ use std::path::Path;
use crate::support::cargo_process;
use crate::support::registry::Package;
use crate::support::{
basic_manifest, git, path2url, paths, project, publish::validate_crate_contents,
registry,
basic_manifest, git, path2url, paths, project, publish::validate_crate_contents, registry,
};
use git2;

Expand Down Expand Up @@ -880,9 +879,7 @@ fn ignore_workspace_specifier() {
.file("bar/src/lib.rs", "")
.build();

p.cargo("package --no-verify")
.cwd("bar")
.run();
p.cargo("package --no-verify").cwd("bar").run();

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

p.cargo("package --features required").masquerade_as_nightly_cargo().run();
p.cargo("package --features required")
.masquerade_as_nightly_cargo()
.run();
}

#[test]
Expand Down Expand Up @@ -1285,7 +1284,9 @@ fn package_with_all_features() {
)
.build();

p.cargo("package --all-features").masquerade_as_nightly_cargo().run();
p.cargo("package --all-features")
.masquerade_as_nightly_cargo()
.run();
}

#[test]
Expand Down
5 changes: 4 additions & 1 deletion tests/testsuite/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,10 @@ fn default_run_workspace() {
.file("b/src/main.rs", r#"fn main() {println!("run-b");}"#)
.build();

p.cargo("run").masquerade_as_nightly_cargo().with_stdout("run-a").run();
p.cargo("run")
.masquerade_as_nightly_cargo()
.with_stdout("run-a")
.run();
}

#[test]
Expand Down
28 changes: 14 additions & 14 deletions tests/testsuite/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,18 +164,20 @@ fn cargo_test_quiet_with_harness() {
fn main() {}
#[test] fn test_hello() {}
"#,
).build();
)
.build();

p.cargo("test -q")
.with_stdout(
"
p.cargo("test -q")
.with_stdout(
"
running 1 test
.
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
"
).with_stderr("")
.run();
",
)
.with_stderr("")
.run();
}

#[test]
Expand Down Expand Up @@ -205,13 +207,10 @@ fn cargo_test_quiet_no_harness() {
fn main() {}
#[test] fn test_hello() {}
"#,
).build();
)
.build();

p.cargo("test -q")
.with_stdout(
""
).with_stderr("")
.run();
p.cargo("test -q").with_stdout("").with_stderr("").run();
}

#[test]
Expand Down Expand Up @@ -1553,7 +1552,8 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
",
)
.with_stderr("\
.with_stderr(
"\
[COMPILING] foo v0.0.1 ([CWD])
[RUNNING] `rustc --crate-name foo src/lib.rs [..] --test [..]`
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
Expand Down
18 changes: 12 additions & 6 deletions tests/testsuite/tool_paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,13 @@ fn custom_runner_cfg() {

p.cargo("run -- --param")
.with_status(101)
.with_stderr_contains("\
.with_stderr_contains(
"\
[COMPILING] foo v0.0.1 ([CWD])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
[RUNNING] `nonexistent-runner -r target/debug/foo[EXE] --param`
")
",
)
.run();
}

Expand Down Expand Up @@ -220,11 +222,13 @@ fn custom_runner_cfg_precedence() {

p.cargo("run -- --param")
.with_status(101)
.with_stderr_contains("\
.with_stderr_contains(
"\
[COMPILING] foo v0.0.1 ([CWD])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
[RUNNING] `nonexistent-runner -r target/debug/foo[EXE] --param`
")
",
)
.run();
}

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

p.cargo("run -- --param")
.with_status(101)
.with_stderr_contains("\
.with_stderr_contains(
"\
[ERROR] several matching instances of `target.'cfg(..)'.runner` in `.cargo/config`
")
",
)
.run();
}

0 comments on commit f16efff

Please sign in to comment.