Run cargo fmt

This commit is contained in:
Alex Crichton 2019-04-05 12:55:01 -07:00
parent 449411f11d
commit f16efff150
19 changed files with 102 additions and 66 deletions

View file

@ -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",

View file

@ -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",
@ -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

View file

@ -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"))
}

View file

@ -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)?;

View file

@ -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|

View file

@ -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;
@ -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.
///

View file

@ -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;

View file

@ -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())]
}
@ -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);
@ -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)

View file

@ -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 {

View file

@ -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};

View file

@ -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;

View file

@ -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);
}

View file

@ -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")

View file

@ -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());
}

View file

@ -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")

View file

@ -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;
@ -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
@ -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]
@ -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]

View file

@ -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]

View file

@ -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]
@ -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]
@ -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 [..]

View file

@ -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();
}
@ -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();
}
@ -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();
}