From: Eric Huss Date: Sat, 21 Apr 2018 19:16:03 +0000 (-0700) Subject: rustfmt X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~1^2~41^2~8 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=a4947c2b47fd38857c7332d333fda7bcc405de0c;p=cargo.git rustfmt --- diff --git a/src/cargo/core/compiler/context/compilation_files.rs b/src/cargo/core/compiler/context/compilation_files.rs index 358d320e6..9fcacb336 100644 --- a/src/cargo/core/compiler/context/compilation_files.rs +++ b/src/cargo/core/compiler/context/compilation_files.rs @@ -7,8 +7,8 @@ use std::sync::Arc; use lazycell::LazyCell; -use core::{TargetKind, Workspace}; use super::{Context, FileFlavor, Kind, Layout, Unit}; +use core::{TargetKind, Workspace}; use util::{self, CargoResult}; #[derive(Clone, Hash, Eq, PartialEq, Ord, PartialOrd)] diff --git a/src/cargo/core/compiler/context/mod.rs b/src/cargo/core/compiler/context/mod.rs index f0ef400cd..8326e16d4 100644 --- a/src/cargo/core/compiler/context/mod.rs +++ b/src/cargo/core/compiler/context/mod.rs @@ -7,27 +7,27 @@ use std::sync::Arc; use jobserver::Client; -use core::{Package, PackageId, PackageSet, Resolve, Target}; -use core::{Dependency, Workspace}; use core::profiles::{Profile, Profiles}; +use core::{Dependency, Workspace}; +use core::{Package, PackageId, PackageSet, Resolve, Target}; use ops::CompileMode; -use util::{internal, profile, Cfg, CfgExpr, Config}; use util::errors::{CargoResult, CargoResultExt}; +use util::{internal, profile, Cfg, CfgExpr, Config}; -use super::TargetConfig; use super::custom_build::{self, BuildDeps, BuildScripts, BuildState}; use super::fingerprint::Fingerprint; use super::job_queue::JobQueue; use super::layout::Layout; use super::links::Links; +use super::TargetConfig; use super::{BuildConfig, Compilation, Executor, Kind}; mod unit_dependencies; use self::unit_dependencies::build_unit_dependencies; mod compilation_files; -use self::compilation_files::{CompilationFiles, OutputFile}; pub use self::compilation_files::Metadata; +use self::compilation_files::{CompilationFiles, OutputFile}; mod target_info; pub use self::target_info::{FileFlavor, TargetInfo}; diff --git a/src/cargo/core/compiler/custom_build.rs b/src/cargo/core/compiler/custom_build.rs index 02fd48de0..ff28c0e06 100644 --- a/src/cargo/core/compiler/custom_build.rs +++ b/src/cargo/core/compiler/custom_build.rs @@ -1,15 +1,15 @@ -use std::collections::{BTreeSet, HashSet}; use std::collections::hash_map::{Entry, HashMap}; +use std::collections::{BTreeSet, HashSet}; use std::fs; use std::path::{Path, PathBuf}; use std::str; use std::sync::{Arc, Mutex}; use core::PackageId; -use util::{Cfg, Freshness}; use util::errors::{CargoResult, CargoResultExt}; -use util::{self, internal, paths, profile}; use util::machine_message; +use util::{self, internal, paths, profile}; +use util::{Cfg, Freshness}; use super::job::Work; use super::{fingerprint, Context, Kind, Unit}; diff --git a/src/cargo/core/compiler/fingerprint.rs b/src/cargo/core/compiler/fingerprint.rs index b71b47d85..9020c5cf2 100644 --- a/src/cargo/core/compiler/fingerprint.rs +++ b/src/cargo/core/compiler/fingerprint.rs @@ -5,19 +5,19 @@ use std::path::{Path, PathBuf}; use std::sync::{Arc, Mutex}; use filetime::FileTime; -use serde::ser::{self, Serialize}; use serde::de::{self, Deserialize}; +use serde::ser::{self, Serialize}; use serde_json; use core::{Edition, Package, TargetKind}; use util; -use util::{internal, profile, Dirty, Fresh, Freshness}; use util::errors::{CargoResult, CargoResultExt}; use util::paths; +use util::{internal, profile, Dirty, Fresh, Freshness}; -use super::job::Work; use super::context::{Context, FileFlavor, Unit}; use super::custom_build::BuildDeps; +use super::job::Work; /// A tuple result of the `prepare_foo` functions in this module. /// @@ -353,14 +353,7 @@ impl hash::Hash for Fingerprint { .. } = *self; ( - rustc, - features, - target, - path, - profile, - local, - edition, - rustflags, + rustc, features, target, path, profile, local, edition, rustflags, ).hash(h); h.write_usize(deps.len()); diff --git a/src/cargo/core/compiler/job_queue.rs b/src/cargo/core/compiler/job_queue.rs index a713a6285..026ac0962 100644 --- a/src/cargo/core/compiler/job_queue.rs +++ b/src/cargo/core/compiler/job_queue.rs @@ -1,5 +1,5 @@ -use std::collections::HashSet; use std::collections::hash_map::HashMap; +use std::collections::HashSet; use std::fmt; use std::io; use std::mem; @@ -8,15 +8,15 @@ use std::sync::mpsc::{channel, Receiver, Sender}; use crossbeam::{self, Scope}; use jobserver::{Acquired, HelperThread}; -use core::{PackageId, Target}; use core::profiles::Profile; +use core::{PackageId, Target}; +use handle_error; use ops::CompileMode; -use util::{Config, DependencyQueue, Dirty, Fresh, Freshness}; use util::{internal, profile, CargoResult, CargoResultExt, ProcessBuilder}; -use handle_error; +use util::{Config, DependencyQueue, Dirty, Fresh, Freshness}; -use super::{Context, Kind, Unit}; use super::job::Job; +use super::{Context, Kind, Unit}; /// A management structure of the entire dependency graph to compile. /// diff --git a/src/cargo/core/compiler/mod.rs b/src/cargo/core/compiler/mod.rs index ad9ea2d0d..c0a948cc9 100644 --- a/src/cargo/core/compiler/mod.rs +++ b/src/cargo/core/compiler/mod.rs @@ -9,14 +9,14 @@ use std::sync::Arc; use same_file::is_same_file; use serde_json; -use core::{Feature, PackageId, Target}; use core::profiles::{Lto, Profile}; use core::shell::ColorChoice; +use core::{Feature, PackageId, Target}; use ops::CompileMode; +use util::errors::{CargoResult, CargoResultExt, Internal}; +use util::paths; use util::{self, machine_message, Config, Freshness, ProcessBuilder, Rustc}; use util::{internal, join_paths, profile}; -use util::paths; -use util::errors::{CargoResult, CargoResultExt, Internal}; use self::job::{Job, Work}; use self::job_queue::JobQueue; @@ -631,10 +631,10 @@ fn hardlink_or_copy(src: &Path, dst: &Path) -> CargoResult<()> { } let link_result = if src.is_dir() { - #[cfg(unix)] - use std::os::unix::fs::symlink; #[cfg(target_os = "redox")] use std::os::redox::fs::symlink; + #[cfg(unix)] + use std::os::unix::fs::symlink; #[cfg(windows)] use std::os::windows::fs::symlink_dir as symlink; diff --git a/src/cargo/core/compiler/output_depinfo.rs b/src/cargo/core/compiler/output_depinfo.rs index 242222ef3..a0a006a5d 100644 --- a/src/cargo/core/compiler/output_depinfo.rs +++ b/src/cargo/core/compiler/output_depinfo.rs @@ -1,11 +1,11 @@ use std::collections::{BTreeSet, HashSet}; -use std::io::{BufWriter, Write}; use std::fs::File; +use std::io::{BufWriter, Write}; use std::path::{Path, PathBuf}; use super::{fingerprint, Context, Unit}; -use util::{internal, CargoResult}; use util::paths; +use util::{internal, CargoResult}; fn render_filename>(path: P, basedir: Option<&str>) -> CargoResult { let path = path.as_ref(); diff --git a/src/cargo/core/features.rs b/src/cargo/core/features.rs index 406c969aa..b38c0950e 100644 --- a/src/cargo/core/features.rs +++ b/src/cargo/core/features.rs @@ -133,8 +133,12 @@ macro_rules! features { } macro_rules! stab { - (stable) => (Status::Stable); - (unstable) => (Status::Unstable); + (stable) => { + Status::Stable + }; + (unstable) => { + Status::Unstable + }; } /// A listing of all features in Cargo diff --git a/src/cargo/core/manifest.rs b/src/cargo/core/manifest.rs index e8c111808..5e4210386 100644 --- a/src/cargo/core/manifest.rs +++ b/src/cargo/core/manifest.rs @@ -1,21 +1,21 @@ use std::collections::{BTreeMap, HashMap}; use std::fmt; +use std::hash::{Hash, Hasher}; use std::path::{Path, PathBuf}; use std::rc::Rc; -use std::hash::{Hash, Hasher}; use semver::Version; use serde::ser; use toml; use url::Url; -use core::{Dependency, PackageId, PackageIdSpec, SourceId, Summary}; +use core::interning::InternedString; use core::profiles::Profiles; +use core::{Dependency, PackageId, PackageIdSpec, SourceId, Summary}; use core::{Edition, Feature, Features, WorkspaceConfig}; -use core::interning::InternedString; -use util::Config; -use util::toml::TomlManifest; use util::errors::*; +use util::toml::TomlManifest; +use util::Config; pub enum EitherManifest { Real(Manifest), diff --git a/src/cargo/core/mod.rs b/src/cargo/core/mod.rs index 347772bb8..67578c822 100644 --- a/src/cargo/core/mod.rs +++ b/src/cargo/core/mod.rs @@ -12,18 +12,18 @@ pub use self::source::{GitReference, Source, SourceId, SourceMap}; pub use self::summary::{FeatureMap, FeatureValue, Summary}; pub use self::workspace::{Members, Workspace, WorkspaceConfig, WorkspaceRootConfig}; -pub mod source; -pub mod package; -pub mod package_id; +pub mod compiler; pub mod dependency; +mod features; +mod interning; pub mod manifest; +pub mod package; +pub mod package_id; +mod package_id_spec; +pub mod profiles; +pub mod registry; pub mod resolver; -pub mod summary; pub mod shell; -pub mod registry; -pub mod compiler; -pub mod profiles; -mod interning; -mod package_id_spec; +pub mod source; +pub mod summary; mod workspace; -mod features; diff --git a/src/cargo/core/profiles.rs b/src/cargo/core/profiles.rs index 71ee27102..70d6a1fe5 100644 --- a/src/cargo/core/profiles.rs +++ b/src/cargo/core/profiles.rs @@ -1,12 +1,12 @@ -use std::{cmp, fmt, hash}; use std::collections::HashSet; +use std::{cmp, fmt, hash}; -use core::Shell; use core::interning::InternedString; +use core::Shell; use ops::CompileMode; -use util::CargoResult; use util::lev_distance::lev_distance; use util::toml::{StringOrBool, TomlProfile, U32OrBool}; +use util::CargoResult; /// Collection of all user profiles. #[derive(Clone, Debug)] diff --git a/src/cargo/core/workspace.rs b/src/cargo/core/workspace.rs index 8f3390454..cd5bc220a 100644 --- a/src/cargo/core/workspace.rs +++ b/src/cargo/core/workspace.rs @@ -1,16 +1,16 @@ use std::cell::RefCell; -use std::collections::BTreeMap; use std::collections::hash_map::{Entry, HashMap}; +use std::collections::BTreeMap; use std::path::{Path, PathBuf}; use std::slice; use glob::glob; use url::Url; +use core::profiles::Profiles; use core::registry::PackageRegistry; use core::{Dependency, PackageIdSpec}; use core::{EitherManifest, Package, SourceId, VirtualManifest}; -use core::profiles::Profiles; use ops; use sources::PathSource; use util::errors::{CargoResult, CargoResultExt}; diff --git a/src/cargo/ops/cargo_clean.rs b/src/cargo/ops/cargo_clean.rs index 3c0321c42..72b196699 100644 --- a/src/cargo/ops/cargo_clean.rs +++ b/src/cargo/ops/cargo_clean.rs @@ -1,13 +1,13 @@ use std::fs; use std::path::Path; -use core::Workspace; use core::compiler::{BuildConfig, Context, Kind, Unit}; use core::profiles::ProfileFor; -use util::Config; +use core::Workspace; +use ops::{self, CompileMode}; use util::errors::{CargoResult, CargoResultExt}; use util::paths; -use ops::{self, CompileMode}; +use util::Config; pub struct CleanOptions<'a> { pub config: &'a Config, diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index dec8cb196..e0c4e0b1e 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -575,64 +575,68 @@ fn generate_targets<'a>( let mut units = Vec::new(); // Helper for creating a Unit struct. - let new_unit = - |pkg: &'a Package, target: &'a Target, target_mode: CompileMode| { - let profile_for = if mode.is_any_test() { - // NOTE: The ProfileFor here is subtle. If you have a profile - // with `panic` set, the `panic` flag is cleared for - // tests/benchmarks and their dependencies. If we left this - // as an "Any" profile, then the lib would get compiled three - // times (once with panic, once without, and once with - // --test). - // - // This would cause a problem for Doc tests, which would fail - // because `rustdoc` would attempt to link with both libraries - // at the same time. Also, it's probably not important (or - // even desirable?) for rustdoc to link with a lib with - // `panic` set. - // - // As a consequence, Examples and Binaries get compiled - // without `panic` set. This probably isn't a bad deal. - // - // Forcing the lib to be compiled three times during `cargo - // test` is probably also not desirable. - ProfileFor::TestDependency - } else { - ProfileFor::Any - }; - let target_mode = match target_mode { - CompileMode::Test => { - if target.is_example() { - // Examples are included as regular binaries to verify - // that they compile. - CompileMode::Build - } else { - CompileMode::Test - } + let new_unit = |pkg: &'a Package, target: &'a Target, target_mode: CompileMode| { + let profile_for = if mode.is_any_test() { + // NOTE: The ProfileFor here is subtle. If you have a profile + // with `panic` set, the `panic` flag is cleared for + // tests/benchmarks and their dependencies. If we left this + // as an "Any" profile, then the lib would get compiled three + // times (once with panic, once without, and once with + // --test). + // + // This would cause a problem for Doc tests, which would fail + // because `rustdoc` would attempt to link with both libraries + // at the same time. Also, it's probably not important (or + // even desirable?) for rustdoc to link with a lib with + // `panic` set. + // + // As a consequence, Examples and Binaries get compiled + // without `panic` set. This probably isn't a bad deal. + // + // Forcing the lib to be compiled three times during `cargo + // test` is probably also not desirable. + ProfileFor::TestDependency + } else { + ProfileFor::Any + }; + let target_mode = match target_mode { + CompileMode::Test => { + if target.is_example() { + // Examples are included as regular binaries to verify + // that they compile. + CompileMode::Build + } else { + CompileMode::Test } - CompileMode::Build => match *target.kind() { - TargetKind::Test => CompileMode::Test, - TargetKind::Bench => CompileMode::Bench, - _ => CompileMode::Build, - }, - _ => target_mode, - }; - // Plugins or proc-macro should be built for the host. - let kind = if target.for_host() { - Kind::Host - } else { - default_arch_kind - }; - let profile = - profiles.get_profile(&pkg.name(), ws.is_member(pkg), profile_for, target_mode, release); - Unit { - pkg, - target, - profile, - kind, - mode: target_mode, } + CompileMode::Build => match *target.kind() { + TargetKind::Test => CompileMode::Test, + TargetKind::Bench => CompileMode::Bench, + _ => CompileMode::Build, + }, + _ => target_mode, }; + // Plugins or proc-macro should be built for the host. + let kind = if target.for_host() { + Kind::Host + } else { + default_arch_kind + }; + let profile = profiles.get_profile( + &pkg.name(), + ws.is_member(pkg), + profile_for, + target_mode, + release, + ); + Unit { + pkg, + target, + profile, + kind, + mode: target_mode, + } + }; for pkg in packages { let features = resolve_all_features(resolve, pkg.package_id()); @@ -650,21 +654,13 @@ fn generate_targets<'a>( } => { let default_units = generate_default_targets(pkg.targets(), mode) .iter() - .map(|t| { - ( - new_unit(pkg, t, mode), - !required_features_filterable, - ) - }) + .map(|t| (new_unit(pkg, t, mode), !required_features_filterable)) .collect::>(); proposals.extend(default_units); if mode == CompileMode::Test { // Include the lib as it will be required for doctests. if let Some(t) = pkg.targets().iter().find(|t| t.is_lib() && t.doctested()) { - proposals.push(( - new_unit(pkg, t, CompileMode::Build), - false, - )); + proposals.push((new_unit(pkg, t, CompileMode::Build), false)); } } } @@ -713,23 +709,17 @@ fn generate_targets<'a>( .chain( list_rule_targets(pkg, examples, "example", Target::is_example)? .into_iter() - .map(|(t, required)| { - (new_unit(pkg, t, mode), required) - }), + .map(|(t, required)| (new_unit(pkg, t, mode), required)), ) .chain( list_rule_targets(pkg, tests, "test", test_filter)? .into_iter() - .map(|(t, required)| { - (new_unit(pkg, t, test_mode), required) - }), + .map(|(t, required)| (new_unit(pkg, t, test_mode), required)), ) .chain( list_rule_targets(pkg, benches, "bench", bench_filter)? .into_iter() - .map(|(t, required)| { - (new_unit(pkg, t, bench_mode), required) - }), + .map(|(t, required)| (new_unit(pkg, t, bench_mode), required)), ) .collect::>(), ); @@ -800,7 +790,10 @@ fn resolve_all_features( fn generate_default_targets(targets: &[Target], mode: CompileMode) -> Vec<&Target> { match mode { CompileMode::Bench => targets.iter().filter(|t| t.benched()).collect(), - CompileMode::Test => targets.iter().filter(|t| t.tested() || t.is_example()).collect(), + CompileMode::Test => targets + .iter() + .filter(|t| t.tested() || t.is_example()) + .collect(), CompileMode::Build | CompileMode::Check { .. } => targets .iter() .filter(|t| t.is_bin() || t.is_lib()) diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index 76f54de91..28cebea35 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -6,22 +6,22 @@ use std::rc::Rc; use std::str; use semver::{self, VersionReq}; -use serde::ser; use serde::de::{self, Deserialize}; +use serde::ser; use serde_ignored; use toml; use url::Url; -use core::{GitReference, PackageIdSpec, SourceId, WorkspaceConfig, WorkspaceRootConfig}; -use core::{Dependency, Manifest, PackageId, Summary, Target}; -use core::{Edition, EitherManifest, Feature, Features, VirtualManifest}; use core::dependency::{Kind, Platform}; use core::manifest::{LibKind, ManifestMetadata}; use core::profiles::Profiles; +use core::{Dependency, Manifest, PackageId, Summary, Target}; +use core::{Edition, EitherManifest, Feature, Features, VirtualManifest}; +use core::{GitReference, PackageIdSpec, SourceId, WorkspaceConfig, WorkspaceRootConfig}; use sources::CRATES_IO; +use util::errors::{CargoError, CargoResult, CargoResultExt}; use util::paths; use util::{self, Config, ToUrl}; -use util::errors::{CargoError, CargoResult, CargoResultExt}; mod targets; use self::targets::targets;