Skip to content

Commit 12cdc77

Browse files
committed
Auto merge of #6400 - alexcrichton:fmt, r=dwijnand
Format with `cargo fmt`
2 parents 41a7e15 + fecb724 commit 12cdc77

File tree

124 files changed

+6211
-3366
lines changed

Some content is hidden

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

124 files changed

+6211
-3366
lines changed

src/bin/cargo/commands/fix.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub fn cli() -> App {
5454
.arg(
5555
Arg::with_name("idioms")
5656
.long("edition-idioms")
57-
.help("Fix warnings to migrate to the idioms of an edition")
57+
.help("Fix warnings to migrate to the idioms of an edition"),
5858
)
5959
.arg(
6060
Arg::with_name("allow-no-vcs")
@@ -133,15 +133,18 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
133133
tests: FilterRule::All,
134134
}
135135
}
136-
ops::fix(&ws, &mut ops::FixOptions {
137-
edition: args.is_present("edition"),
138-
prepare_for: args.value_of("prepare-for"),
139-
idioms: args.is_present("idioms"),
140-
compile_opts: opts,
141-
allow_dirty: args.is_present("allow-dirty"),
142-
allow_no_vcs: args.is_present("allow-no-vcs"),
143-
allow_staged: args.is_present("allow-staged"),
144-
broken_code: args.is_present("broken-code"),
145-
})?;
136+
ops::fix(
137+
&ws,
138+
&mut ops::FixOptions {
139+
edition: args.is_present("edition"),
140+
prepare_for: args.value_of("prepare-for"),
141+
idioms: args.is_present("idioms"),
142+
compile_opts: opts,
143+
allow_dirty: args.is_present("allow-dirty"),
144+
allow_no_vcs: args.is_present("allow-no-vcs"),
145+
allow_staged: args.is_present("allow-staged"),
146+
broken_code: args.is_present("broken-code"),
147+
},
148+
)?;
146149
Ok(())
147150
}

src/bin/cargo/commands/locate_project.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ pub struct ProjectLocation<'a> {
1616
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
1717
let root = args.root_manifest(config)?;
1818

19-
let root = root.to_str()
19+
let root = root
20+
.to_str()
2021
.ok_or_else(|| {
2122
format_err!(
2223
"your package path contains characters \

src/bin/cargo/commands/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ pub fn builtin() -> Vec<App> {
3535
]
3636
}
3737

38-
pub fn builtin_exec(cmd: &str) -> Option<fn(&mut Config, &ArgMatches<'_>) -> CliResult> {
39-
let f = match cmd {
38+
pub fn builtin_exec(cmd: &str) -> Option<fn(&mut Config, &ArgMatches<'_>) -> CliResult> {
39+
let f = match cmd {
4040
"bench" => bench::exec,
4141
"build" => build::exec,
4242
"check" => check::exec,

src/bin/cargo/commands/new.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
2020
} else {
2121
path
2222
};
23-
config
24-
.shell()
25-
.status("Created", format!("{} `{}` package", opts.kind, package_name))?;
23+
config.shell().status(
24+
"Created",
25+
format!("{} `{}` package", opts.kind, package_name),
26+
)?;
2627
Ok(())
2728
}

src/bin/cargo/commands/owner.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ pub fn cli() -> App {
1212
"remove",
1313
"LOGIN",
1414
"Name of a user or team to remove as an owner",
15-
).short("r"),
15+
)
16+
.short("r"),
1617
)
1718
.arg(opt("list", "List owners of a crate").short("l"))
1819
.arg(opt("index", "Registry index to modify owners for").value_name("INDEX"))
1920
.arg(opt("token", "API token to use when authenticating").value_name("TOKEN"))
2021
.arg(opt("registry", "Registry to use").value_name("REGISTRY"))
21-
.after_help("\
22+
.after_help(
23+
"\
2224
This command will modify the owners for a crate on the specified registry (or
2325
default). Owners of a crate can upload new versions and yank old versions.
2426
Explicitly named owners can also modify the set of owners, so take care!
@@ -34,9 +36,11 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
3436
krate: args.value_of("crate").map(|s| s.to_string()),
3537
token: args.value_of("token").map(|s| s.to_string()),
3638
index: args.value_of("index").map(|s| s.to_string()),
37-
to_add: args.values_of("add")
39+
to_add: args
40+
.values_of("add")
3841
.map(|xs| xs.map(|s| s.to_string()).collect()),
39-
to_remove: args.values_of("remove")
42+
to_remove: args
43+
.values_of("remove")
4044
.map(|xs| xs.map(|s| s.to_string()).collect()),
4145
list: args.is_present("list"),
4246
registry,

src/bin/cargo/commands/package.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ pub fn cli() -> App {
99
opt(
1010
"list",
1111
"Print files included in a package without making one",
12-
).short("l"),
12+
)
13+
.short("l"),
1314
)
1415
.arg(opt(
1516
"no-verify",

src/bin/cargo/commands/search.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ pub fn cli() -> App {
1313
opt(
1414
"limit",
1515
"Limit the number of results (default: 10, max: 100)",
16-
).value_name("LIMIT"),
16+
)
17+
.value_name("LIMIT"),
1718
)
1819
.arg(opt("registry", "Registry to use").value_name("REGISTRY"))
1920
}

src/bin/cargo/commands/test.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
9797
let doc = args.is_present("doc");
9898
if doc {
9999
if let CompileFilter::Only { .. } = compile_opts.filter {
100-
return Err(CliError::new(format_err!("Can't mix --doc with other target selecting options"), 101))
100+
return Err(CliError::new(
101+
format_err!("Can't mix --doc with other target selecting options"),
102+
101,
103+
));
101104
}
102105
compile_opts.build_config.mode = CompileMode::Doctest;
103106
compile_opts.filter = ops::CompileFilter::new(

src/bin/cargo/main.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
#![cfg_attr(feature = "cargo-clippy", allow(clippy::too_many_arguments))] // large project
2-
#![cfg_attr(feature = "cargo-clippy", allow(clippy::redundant_closure))] // there's a false positive
2+
#![cfg_attr(feature = "cargo-clippy", allow(clippy::redundant_closure))] // there's a false positive
33

44
use cargo;
55

6-
#[cfg(feature = "pretty-env-logger")]
7-
extern crate pretty_env_logger;
86
#[cfg(not(feature = "pretty-env-logger"))]
97
extern crate env_logger;
8+
#[cfg(feature = "pretty-env-logger")]
9+
extern crate pretty_env_logger;
1010
#[macro_use]
1111
extern crate failure;
1212
use git2_curl;
1313

1414
#[macro_use]
1515
extern crate serde_derive;
1616

17-
18-
1917
use std::collections::BTreeSet;
2018
use std::env;
2119
use std::fs;

src/cargo/core/compiler/build_plan.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ use std::collections::BTreeMap;
1111
use super::context::OutputFile;
1212
use super::{CompileMode, Context, Kind, Unit};
1313
use crate::core::TargetKind;
14+
use crate::util::{internal, CargoResult, ProcessBuilder};
1415
use semver;
1516
use serde_json;
1617
use std::path::PathBuf;
17-
use crate::util::{internal, CargoResult, ProcessBuilder};
1818

1919
#[derive(Debug, Serialize)]
2020
struct Invocation {

src/cargo/core/features.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,11 @@ impl FromStr for Edition {
7777
match s {
7878
"2015" => Ok(Edition::Edition2015),
7979
"2018" => Ok(Edition::Edition2018),
80-
s => {
81-
bail!("supported edition values are `2015` or `2018`, but `{}` \
82-
is unknown", s)
83-
}
80+
s => bail!(
81+
"supported edition values are `2015` or `2018`, but `{}` \
82+
is unknown",
83+
s
84+
),
8485
}
8586
}
8687
}
@@ -396,9 +397,9 @@ thread_local!(
396397
/// that called `masquerade_as_nightly_cargo`
397398
pub fn nightly_features_allowed() -> bool {
398399
if ENABLE_NIGHTLY_FEATURES.with(|c| c.get()) {
399-
return true
400+
return true;
400401
}
401-
match &channel()[..] {
402+
match &channel()[..] {
402403
"nightly" | "dev" => NIGHTLY_FEATURES_ALLOWED.with(|c| c.get()),
403404
_ => false,
404405
}

src/cargo/core/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
pub use self::dependency::Dependency;
2-
pub use self::features::{CliUnstable, Edition, Feature, Features};
32
pub use self::features::{
4-
maybe_allow_nightly_features,
5-
enable_nightly_features,
6-
nightly_features_allowed
3+
enable_nightly_features, maybe_allow_nightly_features, nightly_features_allowed,
74
};
5+
pub use self::features::{CliUnstable, Edition, Feature, Features};
86
pub use self::manifest::{EitherManifest, VirtualManifest};
97
pub use self::manifest::{LibKind, Manifest, Target, TargetKind};
108
pub use self::package::{Package, PackageSet};

src/cargo/core/resolver/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ use std::rc::Rc;
33

44
use crate::core::interning::InternedString;
55
use crate::core::{Dependency, FeatureValue, PackageId, SourceId, Summary};
6-
use im_rc;
76
use crate::util::CargoResult;
87
use crate::util::Graph;
8+
use im_rc;
99

1010
use super::errors::ActivateResult;
1111
use super::types::{ConflictReason, DepInfo, GraphNode, Method, RcList, RegistryQueryer};

src/cargo/core/resolver/errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ use std::collections::BTreeMap;
22
use std::fmt;
33

44
use crate::core::{Dependency, PackageId, Registry, Summary};
5-
use failure::{Error, Fail};
6-
use semver;
75
use crate::util::lev_distance::lev_distance;
86
use crate::util::{CargoError, Config};
7+
use failure::{Error, Fail};
8+
use semver;
99

1010
use super::context::Context;
1111
use super::types::{Candidate, ConflictReason};

src/cargo/lib.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
#![cfg_attr(test, deny(warnings))]
22
// Clippy isn't enforced by CI, and know that @alexcrichton isn't a fan :)
3-
#![cfg_attr(feature = "cargo-clippy", allow(clippy::boxed_local))] // bug rust-lang-nursery/rust-clippy#1123
4-
#![cfg_attr(feature = "cargo-clippy", allow(clippy::cyclomatic_complexity))] // large project
5-
#![cfg_attr(feature = "cargo-clippy", allow(clippy::derive_hash_xor_eq))] // there's an intentional incoherence
3+
#![cfg_attr(feature = "cargo-clippy", allow(clippy::boxed_local))] // bug rust-lang-nursery/rust-clippy#1123
4+
#![cfg_attr(feature = "cargo-clippy", allow(clippy::cyclomatic_complexity))] // large project
5+
#![cfg_attr(feature = "cargo-clippy", allow(clippy::derive_hash_xor_eq))] // there's an intentional incoherence
66
#![cfg_attr(feature = "cargo-clippy", allow(clippy::explicit_into_iter_loop))] // explicit loops are clearer
7-
#![cfg_attr(feature = "cargo-clippy", allow(clippy::explicit_iter_loop))] // explicit loops are clearer
8-
#![cfg_attr(feature = "cargo-clippy", allow(clippy::identity_op))] // used for vertical alignment
9-
#![cfg_attr(feature = "cargo-clippy", allow(clippy::implicit_hasher))] // large project
10-
#![cfg_attr(feature = "cargo-clippy", allow(clippy::large_enum_variant))] // large project
11-
#![cfg_attr(feature = "cargo-clippy", allow(clippy::redundant_closure_call))] // closures over try catch blocks
12-
#![cfg_attr(feature = "cargo-clippy", allow(clippy::too_many_arguments))] // large project
13-
#![cfg_attr(feature = "cargo-clippy", allow(clippy::type_complexity))] // there's an exceptionally complex type
14-
#![cfg_attr(feature = "cargo-clippy", allow(clippy::wrong_self_convention))] // perhaps Rc should be special cased in Clippy?
7+
#![cfg_attr(feature = "cargo-clippy", allow(clippy::explicit_iter_loop))] // explicit loops are clearer
8+
#![cfg_attr(feature = "cargo-clippy", allow(clippy::identity_op))] // used for vertical alignment
9+
#![cfg_attr(feature = "cargo-clippy", allow(clippy::implicit_hasher))] // large project
10+
#![cfg_attr(feature = "cargo-clippy", allow(clippy::large_enum_variant))] // large project
11+
#![cfg_attr(feature = "cargo-clippy", allow(clippy::redundant_closure_call))] // closures over try catch blocks
12+
#![cfg_attr(feature = "cargo-clippy", allow(clippy::too_many_arguments))] // large project
13+
#![cfg_attr(feature = "cargo-clippy", allow(clippy::type_complexity))] // there's an exceptionally complex type
14+
#![cfg_attr(feature = "cargo-clippy", allow(clippy::wrong_self_convention))] // perhaps Rc should be special cased in Clippy?
1515

1616
extern crate atty;
1717
extern crate bytesize;

src/cargo/ops/cargo_compile.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ use std::collections::{HashMap, HashSet};
2626
use std::path::PathBuf;
2727
use std::sync::Arc;
2828

29-
use crate::core::compiler::{BuildConfig, BuildContext, Compilation, Context, DefaultExecutor, Executor};
29+
use crate::core::compiler::{
30+
BuildConfig, BuildContext, Compilation, Context, DefaultExecutor, Executor,
31+
};
3032
use crate::core::compiler::{CompileMode, Kind, Unit};
3133
use crate::core::profiles::{Profiles, UnitFor};
3234
use crate::core::resolver::{Method, Resolve};

src/cargo/ops/cargo_fetch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use crate::core::compiler::{BuildConfig, CompileMode, Kind, TargetInfo};
22
use crate::core::{PackageSet, Resolve, Workspace};
33
use crate::ops;
4-
use std::collections::HashSet;
54
use crate::util::CargoResult;
65
use crate::util::Config;
6+
use std::collections::HashSet;
77

88
pub struct FetchOptions<'a> {
99
pub config: &'a Config,

src/cargo/ops/cargo_run.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use std::iter;
22
use std::path::Path;
33

4+
use crate::core::{nightly_features_allowed, TargetKind, Workspace};
45
use crate::ops;
56
use crate::util::{self, CargoResult, ProcessError};
6-
use crate::core::{TargetKind, Workspace, nightly_features_allowed};
77

88
pub fn run(
99
ws: &Workspace,
@@ -19,13 +19,16 @@ pub fn run(
1919
.into_iter()
2020
.flat_map(|pkg| {
2121
iter::repeat(pkg).zip(pkg.manifest().targets().iter().filter(|target| {
22-
!target.is_lib() && !target.is_custom_build() && if !options.filter.is_specific() {
23-
target.is_bin()
24-
} else {
25-
options.filter.target_run(target)
26-
}
22+
!target.is_lib()
23+
&& !target.is_custom_build()
24+
&& if !options.filter.is_specific() {
25+
target.is_bin()
26+
} else {
27+
options.filter.target_run(target)
28+
}
2729
}))
28-
}).collect();
30+
})
31+
.collect();
2932

3033
if bins.is_empty() {
3134
if !options.filter.is_specific() {

src/cargo/ops/mod.rs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,30 @@
11
pub use self::cargo_clean::{clean, CleanOptions};
22
pub use self::cargo_compile::{compile, compile_with_exec, compile_ws, CompileOptions};
33
pub use self::cargo_compile::{CompileFilter, FilterRule, Packages};
4-
pub use self::cargo_read_manifest::{read_package, read_packages};
5-
pub use self::cargo_run::run;
6-
pub use self::cargo_install::{install, install_list, uninstall};
7-
pub use self::cargo_new::{init, new, NewOptions, VersionControl};
84
pub use self::cargo_doc::{doc, DocOptions};
5+
pub use self::cargo_fetch::{fetch, FetchOptions};
96
pub use self::cargo_generate_lockfile::generate_lockfile;
107
pub use self::cargo_generate_lockfile::update_lockfile;
118
pub use self::cargo_generate_lockfile::UpdateOptions;
12-
pub use self::lockfile::{load_pkg_lockfile, write_pkg_lockfile};
13-
pub use self::cargo_test::{run_benches, run_tests, TestOptions};
9+
pub use self::cargo_install::{install, install_list, uninstall};
10+
pub use self::cargo_new::{init, new, NewOptions, VersionControl};
11+
pub use self::cargo_output_metadata::{output_metadata, ExportInfo, OutputMetadataOptions};
1412
pub use self::cargo_package::{package, PackageOpts};
15-
pub use self::registry::{publish, registry_configuration, RegistryConfig};
13+
pub use self::cargo_pkgid::pkgid;
14+
pub use self::cargo_read_manifest::{read_package, read_packages};
15+
pub use self::cargo_run::run;
16+
pub use self::cargo_test::{run_benches, run_tests, TestOptions};
17+
pub use self::fix::{fix, fix_maybe_exec_rustc, FixOptions};
18+
pub use self::lockfile::{load_pkg_lockfile, write_pkg_lockfile};
19+
pub use self::registry::HttpTimeout;
20+
pub use self::registry::{configure_http_handle, http_handle_and_timeout};
1621
pub use self::registry::{http_handle, needs_custom_http_transport, registry_login, search};
1722
pub use self::registry::{modify_owners, yank, OwnersOptions, PublishOpts};
18-
pub use self::registry::{configure_http_handle, http_handle_and_timeout};
19-
pub use self::registry::HttpTimeout;
20-
pub use self::cargo_fetch::{fetch, FetchOptions};
21-
pub use self::cargo_pkgid::pkgid;
22-
pub use self::resolve::{add_overrides, get_resolved_packages, resolve_with_previous, resolve_ws,
23-
resolve_ws_precisely, resolve_ws_with_method};
24-
pub use self::cargo_output_metadata::{output_metadata, ExportInfo, OutputMetadataOptions};
25-
pub use self::fix::{fix, FixOptions, fix_maybe_exec_rustc};
23+
pub use self::registry::{publish, registry_configuration, RegistryConfig};
24+
pub use self::resolve::{
25+
add_overrides, get_resolved_packages, resolve_with_previous, resolve_ws, resolve_ws_precisely,
26+
resolve_ws_with_method,
27+
};
2628

2729
mod cargo_clean;
2830
mod cargo_compile;
@@ -37,7 +39,7 @@ mod cargo_pkgid;
3739
mod cargo_read_manifest;
3840
mod cargo_run;
3941
mod cargo_test;
42+
mod fix;
4043
mod lockfile;
4144
mod registry;
4245
mod resolve;
43-
mod fix;

src/cargo/ops/registry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ use std::str;
55
use std::time::Duration;
66
use std::{cmp, env};
77

8+
use crate::registry::{NewCrate, NewCrateDependency, Registry};
89
use curl::easy::{Easy, InfoType, SslOpt};
910
use git2;
1011
use log::Level;
11-
use crate::registry::{NewCrate, NewCrateDependency, Registry};
1212

1313
use url::percent_encoding::{percent_encode, QUERY_ENCODE_SET};
1414

src/cargo/sources/git/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pub use self::utils::{fetch, GitCheckout, GitDatabase, GitRemote, GitRevision};
21
pub use self::source::{canonicalize_url, GitSource};
3-
mod utils;
2+
pub use self::utils::{fetch, GitCheckout, GitDatabase, GitRemote, GitRevision};
43
mod source;
4+
mod utils;

0 commit comments

Comments
 (0)