Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format with cargo fmt #6400

Merged
merged 2 commits into from
Dec 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions src/bin/cargo/commands/fix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub fn cli() -> App {
.arg(
Arg::with_name("idioms")
.long("edition-idioms")
.help("Fix warnings to migrate to the idioms of an edition")
.help("Fix warnings to migrate to the idioms of an edition"),
)
.arg(
Arg::with_name("allow-no-vcs")
Expand Down Expand Up @@ -133,15 +133,18 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
tests: FilterRule::All,
}
}
ops::fix(&ws, &mut ops::FixOptions {
edition: args.is_present("edition"),
prepare_for: args.value_of("prepare-for"),
idioms: args.is_present("idioms"),
compile_opts: opts,
allow_dirty: args.is_present("allow-dirty"),
allow_no_vcs: args.is_present("allow-no-vcs"),
allow_staged: args.is_present("allow-staged"),
broken_code: args.is_present("broken-code"),
})?;
ops::fix(
&ws,
&mut ops::FixOptions {
edition: args.is_present("edition"),
prepare_for: args.value_of("prepare-for"),
idioms: args.is_present("idioms"),
compile_opts: opts,
allow_dirty: args.is_present("allow-dirty"),
allow_no_vcs: args.is_present("allow-no-vcs"),
allow_staged: args.is_present("allow-staged"),
broken_code: args.is_present("broken-code"),
},
)?;
Ok(())
}
3 changes: 2 additions & 1 deletion src/bin/cargo/commands/locate_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ pub struct ProjectLocation<'a> {
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let root = args.root_manifest(config)?;

let root = root.to_str()
let root = root
.to_str()
.ok_or_else(|| {
format_err!(
"your package path contains characters \
Expand Down
4 changes: 2 additions & 2 deletions src/bin/cargo/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ pub fn builtin() -> Vec<App> {
]
}

pub fn builtin_exec(cmd: &str) -> Option<fn(&mut Config, &ArgMatches<'_>) -> CliResult> {
let f = match cmd {
pub fn builtin_exec(cmd: &str) -> Option<fn(&mut Config, &ArgMatches<'_>) -> CliResult> {
let f = match cmd {
"bench" => bench::exec,
"build" => build::exec,
"check" => check::exec,
Expand Down
7 changes: 4 additions & 3 deletions src/bin/cargo/commands/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
} else {
path
};
config
.shell()
.status("Created", format!("{} `{}` package", opts.kind, package_name))?;
config.shell().status(
"Created",
format!("{} `{}` package", opts.kind, package_name),
)?;
Ok(())
}
12 changes: 8 additions & 4 deletions src/bin/cargo/commands/owner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ pub fn cli() -> App {
"remove",
"LOGIN",
"Name of a user or team to remove as an owner",
).short("r"),
)
.short("r"),
)
.arg(opt("list", "List owners of a crate").short("l"))
.arg(opt("index", "Registry index to modify owners for").value_name("INDEX"))
.arg(opt("token", "API token to use when authenticating").value_name("TOKEN"))
.arg(opt("registry", "Registry to use").value_name("REGISTRY"))
.after_help("\
.after_help(
"\
This command will modify the owners for a crate on the specified registry (or
default). Owners of a crate can upload new versions and yank old versions.
Explicitly named owners can also modify the set of owners, so take care!
Expand All @@ -34,9 +36,11 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
krate: args.value_of("crate").map(|s| s.to_string()),
token: args.value_of("token").map(|s| s.to_string()),
index: args.value_of("index").map(|s| s.to_string()),
to_add: args.values_of("add")
to_add: args
.values_of("add")
.map(|xs| xs.map(|s| s.to_string()).collect()),
to_remove: args.values_of("remove")
to_remove: args
.values_of("remove")
.map(|xs| xs.map(|s| s.to_string()).collect()),
list: args.is_present("list"),
registry,
Expand Down
3 changes: 2 additions & 1 deletion src/bin/cargo/commands/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ pub fn cli() -> App {
opt(
"list",
"Print files included in a package without making one",
).short("l"),
)
.short("l"),
)
.arg(opt(
"no-verify",
Expand Down
3 changes: 2 additions & 1 deletion src/bin/cargo/commands/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ pub fn cli() -> App {
opt(
"limit",
"Limit the number of results (default: 10, max: 100)",
).value_name("LIMIT"),
)
.value_name("LIMIT"),
)
.arg(opt("registry", "Registry to use").value_name("REGISTRY"))
}
Expand Down
5 changes: 4 additions & 1 deletion src/bin/cargo/commands/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let doc = args.is_present("doc");
if doc {
if let CompileFilter::Only { .. } = compile_opts.filter {
return Err(CliError::new(format_err!("Can't mix --doc with other target selecting options"), 101))
return Err(CliError::new(
format_err!("Can't mix --doc with other target selecting options"),
101,
));
}
compile_opts.build_config.mode = CompileMode::Doctest;
compile_opts.filter = ops::CompileFilter::new(
Expand Down
8 changes: 3 additions & 5 deletions src/bin/cargo/main.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
#![cfg_attr(feature = "cargo-clippy", allow(clippy::too_many_arguments))] // large project
#![cfg_attr(feature = "cargo-clippy", allow(clippy::redundant_closure))] // there's a false positive
#![cfg_attr(feature = "cargo-clippy", allow(clippy::redundant_closure))] // there's a false positive

use cargo;

#[cfg(feature = "pretty-env-logger")]
extern crate pretty_env_logger;
#[cfg(not(feature = "pretty-env-logger"))]
extern crate env_logger;
#[cfg(feature = "pretty-env-logger")]
extern crate pretty_env_logger;
#[macro_use]
extern crate failure;
use git2_curl;

#[macro_use]
extern crate serde_derive;



use std::collections::BTreeSet;
use std::env;
use std::fs;
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/core/compiler/build_plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ use std::collections::BTreeMap;
use super::context::OutputFile;
use super::{CompileMode, Context, Kind, Unit};
use crate::core::TargetKind;
use crate::util::{internal, CargoResult, ProcessBuilder};
use semver;
use serde_json;
use std::path::PathBuf;
use crate::util::{internal, CargoResult, ProcessBuilder};

#[derive(Debug, Serialize)]
struct Invocation {
Expand Down
13 changes: 7 additions & 6 deletions src/cargo/core/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,11 @@ impl FromStr for Edition {
match s {
"2015" => Ok(Edition::Edition2015),
"2018" => Ok(Edition::Edition2018),
s => {
bail!("supported edition values are `2015` or `2018`, but `{}` \
is unknown", s)
}
s => bail!(
"supported edition values are `2015` or `2018`, but `{}` \
is unknown",
s
),
}
}
}
Expand Down Expand Up @@ -396,9 +397,9 @@ thread_local!(
/// that called `masquerade_as_nightly_cargo`
pub fn nightly_features_allowed() -> bool {
if ENABLE_NIGHTLY_FEATURES.with(|c| c.get()) {
return true
return true;
}
match &channel()[..] {
match &channel()[..] {
"nightly" | "dev" => NIGHTLY_FEATURES_ALLOWED.with(|c| c.get()),
_ => false,
}
Expand Down
6 changes: 2 additions & 4 deletions src/cargo/core/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
pub use self::dependency::Dependency;
pub use self::features::{CliUnstable, Edition, Feature, Features};
pub use self::features::{
maybe_allow_nightly_features,
enable_nightly_features,
nightly_features_allowed
enable_nightly_features, maybe_allow_nightly_features, nightly_features_allowed,
};
pub use self::features::{CliUnstable, Edition, Feature, Features};
pub use self::manifest::{EitherManifest, VirtualManifest};
pub use self::manifest::{LibKind, Manifest, Target, TargetKind};
pub use self::package::{Package, PackageSet};
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/core/resolver/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use std::rc::Rc;

use crate::core::interning::InternedString;
use crate::core::{Dependency, FeatureValue, PackageId, SourceId, Summary};
use im_rc;
use crate::util::CargoResult;
use crate::util::Graph;
use im_rc;

use super::errors::ActivateResult;
use super::types::{ConflictReason, DepInfo, GraphNode, Method, RcList, RegistryQueryer};
Expand Down
4 changes: 2 additions & 2 deletions src/cargo/core/resolver/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use std::collections::BTreeMap;
use std::fmt;

use crate::core::{Dependency, PackageId, Registry, Summary};
use failure::{Error, Fail};
use semver;
use crate::util::lev_distance::lev_distance;
use crate::util::{CargoError, Config};
use failure::{Error, Fail};
use semver;

use super::context::Context;
use super::types::{Candidate, ConflictReason};
Expand Down
22 changes: 11 additions & 11 deletions src/cargo/lib.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#![cfg_attr(test, deny(warnings))]
// Clippy isn't enforced by CI, and know that @alexcrichton isn't a fan :)
#![cfg_attr(feature = "cargo-clippy", allow(clippy::boxed_local))] // bug rust-lang-nursery/rust-clippy#1123
#![cfg_attr(feature = "cargo-clippy", allow(clippy::cyclomatic_complexity))] // large project
#![cfg_attr(feature = "cargo-clippy", allow(clippy::derive_hash_xor_eq))] // there's an intentional incoherence
#![cfg_attr(feature = "cargo-clippy", allow(clippy::boxed_local))] // bug rust-lang-nursery/rust-clippy#1123
#![cfg_attr(feature = "cargo-clippy", allow(clippy::cyclomatic_complexity))] // large project
#![cfg_attr(feature = "cargo-clippy", allow(clippy::derive_hash_xor_eq))] // there's an intentional incoherence
#![cfg_attr(feature = "cargo-clippy", allow(clippy::explicit_into_iter_loop))] // explicit loops are clearer
#![cfg_attr(feature = "cargo-clippy", allow(clippy::explicit_iter_loop))] // explicit loops are clearer
#![cfg_attr(feature = "cargo-clippy", allow(clippy::identity_op))] // used for vertical alignment
#![cfg_attr(feature = "cargo-clippy", allow(clippy::implicit_hasher))] // large project
#![cfg_attr(feature = "cargo-clippy", allow(clippy::large_enum_variant))] // large project
#![cfg_attr(feature = "cargo-clippy", allow(clippy::redundant_closure_call))] // closures over try catch blocks
#![cfg_attr(feature = "cargo-clippy", allow(clippy::too_many_arguments))] // large project
#![cfg_attr(feature = "cargo-clippy", allow(clippy::type_complexity))] // there's an exceptionally complex type
#![cfg_attr(feature = "cargo-clippy", allow(clippy::wrong_self_convention))] // perhaps Rc should be special cased in Clippy?
#![cfg_attr(feature = "cargo-clippy", allow(clippy::explicit_iter_loop))] // explicit loops are clearer
#![cfg_attr(feature = "cargo-clippy", allow(clippy::identity_op))] // used for vertical alignment
#![cfg_attr(feature = "cargo-clippy", allow(clippy::implicit_hasher))] // large project
#![cfg_attr(feature = "cargo-clippy", allow(clippy::large_enum_variant))] // large project
#![cfg_attr(feature = "cargo-clippy", allow(clippy::redundant_closure_call))] // closures over try catch blocks
#![cfg_attr(feature = "cargo-clippy", allow(clippy::too_many_arguments))] // large project
#![cfg_attr(feature = "cargo-clippy", allow(clippy::type_complexity))] // there's an exceptionally complex type
#![cfg_attr(feature = "cargo-clippy", allow(clippy::wrong_self_convention))] // perhaps Rc should be special cased in Clippy?

extern crate atty;
extern crate bytesize;
Expand Down
4 changes: 3 additions & 1 deletion src/cargo/ops/cargo_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ use std::collections::{HashMap, HashSet};
use std::path::PathBuf;
use std::sync::Arc;

use crate::core::compiler::{BuildConfig, BuildContext, Compilation, Context, DefaultExecutor, Executor};
use crate::core::compiler::{
BuildConfig, BuildContext, Compilation, Context, DefaultExecutor, Executor,
};
use crate::core::compiler::{CompileMode, Kind, Unit};
use crate::core::profiles::{Profiles, UnitFor};
use crate::core::resolver::{Method, Resolve};
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/ops/cargo_fetch.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::core::compiler::{BuildConfig, CompileMode, Kind, TargetInfo};
use crate::core::{PackageSet, Resolve, Workspace};
use crate::ops;
use std::collections::HashSet;
use crate::util::CargoResult;
use crate::util::Config;
use std::collections::HashSet;

pub struct FetchOptions<'a> {
pub config: &'a Config,
Expand Down
17 changes: 10 additions & 7 deletions src/cargo/ops/cargo_run.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::iter;
use std::path::Path;

use crate::core::{nightly_features_allowed, TargetKind, Workspace};
use crate::ops;
use crate::util::{self, CargoResult, ProcessError};
use crate::core::{TargetKind, Workspace, nightly_features_allowed};

pub fn run(
ws: &Workspace,
Expand All @@ -19,13 +19,16 @@ pub fn run(
.into_iter()
.flat_map(|pkg| {
iter::repeat(pkg).zip(pkg.manifest().targets().iter().filter(|target| {
!target.is_lib() && !target.is_custom_build() && if !options.filter.is_specific() {
target.is_bin()
} else {
options.filter.target_run(target)
}
!target.is_lib()
&& !target.is_custom_build()
&& if !options.filter.is_specific() {
target.is_bin()
} else {
options.filter.target_run(target)
}
}))
}).collect();
})
.collect();

if bins.is_empty() {
if !options.filter.is_specific() {
Expand Down
34 changes: 18 additions & 16 deletions src/cargo/ops/mod.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
pub use self::cargo_clean::{clean, CleanOptions};
pub use self::cargo_compile::{compile, compile_with_exec, compile_ws, CompileOptions};
pub use self::cargo_compile::{CompileFilter, FilterRule, Packages};
pub use self::cargo_read_manifest::{read_package, read_packages};
pub use self::cargo_run::run;
pub use self::cargo_install::{install, install_list, uninstall};
pub use self::cargo_new::{init, new, NewOptions, VersionControl};
pub use self::cargo_doc::{doc, DocOptions};
pub use self::cargo_fetch::{fetch, FetchOptions};
pub use self::cargo_generate_lockfile::generate_lockfile;
pub use self::cargo_generate_lockfile::update_lockfile;
pub use self::cargo_generate_lockfile::UpdateOptions;
pub use self::lockfile::{load_pkg_lockfile, write_pkg_lockfile};
pub use self::cargo_test::{run_benches, run_tests, TestOptions};
pub use self::cargo_install::{install, install_list, uninstall};
pub use self::cargo_new::{init, new, NewOptions, VersionControl};
pub use self::cargo_output_metadata::{output_metadata, ExportInfo, OutputMetadataOptions};
pub use self::cargo_package::{package, PackageOpts};
pub use self::registry::{publish, registry_configuration, RegistryConfig};
pub use self::cargo_pkgid::pkgid;
pub use self::cargo_read_manifest::{read_package, read_packages};
pub use self::cargo_run::run;
pub use self::cargo_test::{run_benches, run_tests, TestOptions};
pub use self::fix::{fix, fix_maybe_exec_rustc, FixOptions};
pub use self::lockfile::{load_pkg_lockfile, write_pkg_lockfile};
pub use self::registry::HttpTimeout;
pub use self::registry::{configure_http_handle, http_handle_and_timeout};
pub use self::registry::{http_handle, needs_custom_http_transport, registry_login, search};
pub use self::registry::{modify_owners, yank, OwnersOptions, PublishOpts};
pub use self::registry::{configure_http_handle, http_handle_and_timeout};
pub use self::registry::HttpTimeout;
pub use self::cargo_fetch::{fetch, FetchOptions};
pub use self::cargo_pkgid::pkgid;
pub use self::resolve::{add_overrides, get_resolved_packages, resolve_with_previous, resolve_ws,
resolve_ws_precisely, resolve_ws_with_method};
pub use self::cargo_output_metadata::{output_metadata, ExportInfo, OutputMetadataOptions};
pub use self::fix::{fix, FixOptions, fix_maybe_exec_rustc};
pub use self::registry::{publish, registry_configuration, RegistryConfig};
pub use self::resolve::{
add_overrides, get_resolved_packages, resolve_with_previous, resolve_ws, resolve_ws_precisely,
resolve_ws_with_method,
};

mod cargo_clean;
mod cargo_compile;
Expand All @@ -37,7 +39,7 @@ mod cargo_pkgid;
mod cargo_read_manifest;
mod cargo_run;
mod cargo_test;
mod fix;
mod lockfile;
mod registry;
mod resolve;
mod fix;
2 changes: 1 addition & 1 deletion src/cargo/ops/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ use std::str;
use std::time::Duration;
use std::{cmp, env};

use crate::registry::{NewCrate, NewCrateDependency, Registry};
use curl::easy::{Easy, InfoType, SslOpt};
use git2;
use log::Level;
use crate::registry::{NewCrate, NewCrateDependency, Registry};

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

Expand Down
4 changes: 2 additions & 2 deletions src/cargo/sources/git/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub use self::utils::{fetch, GitCheckout, GitDatabase, GitRemote, GitRevision};
pub use self::source::{canonicalize_url, GitSource};
mod utils;
pub use self::utils::{fetch, GitCheckout, GitDatabase, GitRemote, GitRevision};
mod source;
mod utils;
Loading