rustfmt
authorEric Huss <eric@huss.org>
Sat, 21 Apr 2018 19:16:03 +0000 (12:16 -0700)
committerEric Huss <eric@huss.org>
Fri, 27 Apr 2018 20:42:30 +0000 (13:42 -0700)
15 files changed:
src/cargo/core/compiler/context/compilation_files.rs
src/cargo/core/compiler/context/mod.rs
src/cargo/core/compiler/custom_build.rs
src/cargo/core/compiler/fingerprint.rs
src/cargo/core/compiler/job_queue.rs
src/cargo/core/compiler/mod.rs
src/cargo/core/compiler/output_depinfo.rs
src/cargo/core/features.rs
src/cargo/core/manifest.rs
src/cargo/core/mod.rs
src/cargo/core/profiles.rs
src/cargo/core/workspace.rs
src/cargo/ops/cargo_clean.rs
src/cargo/ops/cargo_compile.rs
src/cargo/util/toml/mod.rs

index 358d320e6ca9576104471dfad6a25fa106f1018b..9fcacb33614f3f52b8c1c5b347af4f60bd46370c 100644 (file)
@@ -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)]
index f0ef400cd2d8f4a485ef6a10fbdf6898cddf0990..8326e16d4a4640a302bed74f0f293a75c920abd2 100644 (file)
@@ -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};
index 02fd48de03118f1d645aa60fd383867ca000ff63..ff28c0e065a9201a335723ad99496c48138c6246 100644 (file)
@@ -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};
index b71b47d859c56af14251f140392b8cdbf2a4ab9e..9020c5cf2a8639e2fa2307d515b6e47574a5c585 100644 (file)
@@ -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());
index a713a6285cab66034255e137bd8e007e4c3fb275..026ac0962baa41678ce82bf82ce3c386a95eb3c2 100644 (file)
@@ -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.
 ///
index ad9ea2d0d5f939a154046acc1ac3dda069417a47..c0a948cc9114cb6bfde9649c254f9024b28d0cf1 100644 (file)
@@ -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;
 
index 242222ef31ddc651cdb499973456ad040ed6faf4..a0a006a5d0a5f718a5c541d66a4ff6d782b88db3 100644 (file)
@@ -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<P: AsRef<Path>>(path: P, basedir: Option<&str>) -> CargoResult<String> {
     let path = path.as_ref();
index 406c969aa82620b7649a3f4e1d69d0ac73467539..b38c0950e9e23912093e90dca54bdf98e0177e64 100644 (file)
@@ -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
index e8c111808232ddd9538e080c4e3bc2c2edd9e775..5e42103862c4af60770e46744b1955f92e90efb4 100644 (file)
@@ -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),
index 347772bb810a5496fae5fb79c1616547f7785df7..67578c8223cfd5bb5a628d61e3ca90a8f88c80c1 100644 (file)
@@ -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;
index 71ee27102fea27d780c16a59fe1817f736aca5f7..70d6a1fe5e5a473b48246e208782a0e49d003332 100644 (file)
@@ -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)]
index 8f339045407f09a0c7f676579a8e3589c31018d4..cd5bc220a3ca32bf12a19accc113cee1c22095ce 100644 (file)
@@ -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};
index 3c0321c42ff38bbcea2bbd052c3006be5d67cf51..72b1966990b19521208a1c8169ec3b32940cecd5 100644 (file)
@@ -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,
index dec8cb196d5b693c7d6ef44aefe32c2c9dba277b..e0c4e0b1e40df305a06d6acfdef71f8cd8ed0496 100644 (file)
@@ -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::<Vec<_>>();
                 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::<Vec<_>>(),
                 );
@@ -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())
index 76f54de916f6f3a6e85de44149040272701a0e42..28cebea35d30e67d203ec2098b91253d13471577 100644 (file)
@@ -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;