diff --git a/src/bin/bench.rs b/src/bin/bench.rs index e00002ebe97..f42e5a73eb6 100644 --- a/src/bin/bench.rs +++ b/src/bin/bench.rs @@ -121,13 +121,13 @@ pub fn execute(mut options: Options, config: &mut Config) -> CliResult { no_fail_fast: options.flag_no_fail_fast, only_doc: false, compile_opts: ops::CompileOptions { - config: config, + config, jobs: options.flag_jobs, target: options.flag_target.as_ref().map(|s| &s[..]), features: &options.flag_features, all_features: options.flag_all_features, no_default_features: options.flag_no_default_features, - spec: spec, + spec, release: true, mode: ops::CompileMode::Bench, filter: ops::CompileFilter::new(options.flag_lib, diff --git a/src/bin/build.rs b/src/bin/build.rs index 889052068e4..9dd2fa24efa 100644 --- a/src/bin/build.rs +++ b/src/bin/build.rs @@ -105,13 +105,13 @@ pub fn execute(options: Options, config: &mut Config) -> CliResult { &options.flag_package)?; let opts = CompileOptions { - config: config, + config, jobs: options.flag_jobs, target: options.flag_target.as_ref().map(|t| &t[..]), features: &options.flag_features, all_features: options.flag_all_features, no_default_features: options.flag_no_default_features, - spec: spec, + spec, mode: ops::CompileMode::Build, release: options.flag_release, filter: ops::CompileFilter::new(options.flag_lib, diff --git a/src/bin/check.rs b/src/bin/check.rs index 98172a28c1b..53e8128e163 100644 --- a/src/bin/check.rs +++ b/src/bin/check.rs @@ -121,14 +121,14 @@ pub fn execute(options: Options, config: &mut Config) -> CliResult { }; let opts = CompileOptions { - config: config, + config, jobs: options.flag_jobs, target: options.flag_target.as_ref().map(|t| &t[..]), features: &options.flag_features, all_features: options.flag_all_features, no_default_features: options.flag_no_default_features, - spec: spec, - mode: ops::CompileMode::Check{test:test}, + spec, + mode: ops::CompileMode::Check{test }, release: options.flag_release, filter: ops::CompileFilter::new(options.flag_lib, &options.flag_bin, options.flag_bins, diff --git a/src/bin/clean.rs b/src/bin/clean.rs index 446b5e502b2..fc226b4adc6 100644 --- a/src/bin/clean.rs +++ b/src/bin/clean.rs @@ -56,7 +56,7 @@ pub fn execute(options: Options, config: &mut Config) -> CliResult { let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?; let opts = ops::CleanOptions { - config: config, + config, spec: &options.flag_package, target: options.flag_target.as_ref().map(|s| &s[..]), release: options.flag_release, diff --git a/src/bin/doc.rs b/src/bin/doc.rs index c0ffcddedf2..d4124fc089c 100644 --- a/src/bin/doc.rs +++ b/src/bin/doc.rs @@ -98,13 +98,13 @@ pub fn execute(options: Options, config: &mut Config) -> CliResult { let doc_opts = ops::DocOptions { open_result: options.flag_open, compile_opts: ops::CompileOptions { - config: config, + config, jobs: options.flag_jobs, target: options.flag_target.as_ref().map(|t| &t[..]), features: &options.flag_features, all_features: options.flag_all_features, no_default_features: options.flag_no_default_features, - spec: spec, + spec, filter: ops::CompileFilter::new(options.flag_lib, &options.flag_bin, options.flag_bins, &empty, false, diff --git a/src/bin/install.rs b/src/bin/install.rs index a0c000202fc..af18a839c59 100644 --- a/src/bin/install.rs +++ b/src/bin/install.rs @@ -118,7 +118,7 @@ pub fn execute(options: Options, config: &mut Config) -> CliResult { &options.flag_z)?; let compile_opts = ops::CompileOptions { - config: config, + config, jobs: options.flag_jobs, target: None, features: &options.flag_features, diff --git a/src/bin/package.rs b/src/bin/package.rs index 9c91583d0e8..4db0db86f46 100644 --- a/src/bin/package.rs +++ b/src/bin/package.rs @@ -54,7 +54,7 @@ pub fn execute(options: Options, config: &mut Config) -> CliResult { let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?; let ws = Workspace::new(&root, config)?; ops::package(&ws, &ops::PackageOpts { - config: config, + config, verify: !options.flag_no_verify, list: options.flag_list, check_metadata: !options.flag_no_metadata, diff --git a/src/bin/publish.rs b/src/bin/publish.rs index 7294ea70ee6..71d7efc537b 100644 --- a/src/bin/publish.rs +++ b/src/bin/publish.rs @@ -97,17 +97,17 @@ about this warning."; let root = find_root_manifest_for_wd(flag_manifest_path.clone(), config.cwd())?; let ws = Workspace::new(&root, config)?; ops::publish(&ws, &ops::PublishOpts { - config: config, - token: token, + config, + token, index: if host.clone().is_none() || host.clone().unwrap().is_empty() { index } else { config.shell().warn(&msg)?; host }, // TODO: Deprecated, remove verify: !no_verify, - allow_dirty: allow_dirty, + allow_dirty, target: target.as_ref().map(|t| &t[..]), - jobs: jobs, - dry_run: dry_run, - registry: registry, + jobs, + dry_run, + registry, })?; Ok(()) } diff --git a/src/bin/run.rs b/src/bin/run.rs index 48939d6547e..92ccb90dbc7 100644 --- a/src/bin/run.rs +++ b/src/bin/run.rs @@ -86,13 +86,13 @@ pub fn execute(options: Options, config: &mut Config) -> CliResult { let spec = Packages::Packages(&packages); let compile_opts = ops::CompileOptions { - config: config, + config, jobs: options.flag_jobs, target: options.flag_target.as_ref().map(|t| &t[..]), features: &options.flag_features, all_features: options.flag_all_features, no_default_features: options.flag_no_default_features, - spec: spec, + spec, release: options.flag_release, mode: ops::CompileMode::Build, filter: if examples.is_empty() && bins.is_empty() { diff --git a/src/bin/rustc.rs b/src/bin/rustc.rs index 98d7c410de4..a73e47ddcff 100644 --- a/src/bin/rustc.rs +++ b/src/bin/rustc.rs @@ -113,14 +113,14 @@ pub fn execute(options: Options, config: &mut Config) -> CliResult { let spec = options.flag_package.map_or_else(Vec::new, |s| vec![s]); let opts = CompileOptions { - config: config, + config, jobs: options.flag_jobs, target: options.flag_target.as_ref().map(|t| &t[..]), features: &options.flag_features, all_features: options.flag_all_features, no_default_features: options.flag_no_default_features, spec: Packages::Packages(&spec), - mode: mode, + mode, release: options.flag_release, filter: ops::CompileFilter::new(options.flag_lib, &options.flag_bin, options.flag_bins, diff --git a/src/bin/rustdoc.rs b/src/bin/rustdoc.rs index 156a6b86796..f10354619a9 100644 --- a/src/bin/rustdoc.rs +++ b/src/bin/rustdoc.rs @@ -99,7 +99,7 @@ pub fn execute(options: Options, config: &mut Config) -> CliResult { let doc_opts = ops::DocOptions { open_result: options.flag_open, compile_opts: ops::CompileOptions { - config: config, + config, jobs: options.flag_jobs, target: options.flag_target.as_ref().map(|t| &t[..]), features: &options.flag_features, diff --git a/src/bin/test.rs b/src/bin/test.rs index d13e9edbc62..1262894ceb4 100644 --- a/src/bin/test.rs +++ b/src/bin/test.rs @@ -159,16 +159,16 @@ pub fn execute(mut options: Options, config: &mut Config) -> CliResult { no_fail_fast: options.flag_no_fail_fast, only_doc: options.flag_doc, compile_opts: ops::CompileOptions { - config: config, + config, jobs: options.flag_jobs, target: options.flag_target.as_ref().map(|s| &s[..]), features: &options.flag_features, all_features: options.flag_all_features, no_default_features: options.flag_no_default_features, - spec: spec, + spec, release: options.flag_release, - mode: mode, - filter: filter, + mode, + filter, message_format: options.flag_message_format, target_rustdoc_args: None, target_rustc_args: None, diff --git a/src/bin/update.rs b/src/bin/update.rs index 1e7f92b535a..1de78a23eef 100644 --- a/src/bin/update.rs +++ b/src/bin/update.rs @@ -74,7 +74,7 @@ pub fn execute(options: Options, config: &mut Config) -> CliResult { aggressive: options.flag_aggressive, precise: options.flag_precise.as_ref().map(|s| &s[..]), to_update: &options.flag_package, - config: config, + config, }; let ws = Workspace::new(&root, config)?; diff --git a/src/cargo/core/features.rs b/src/cargo/core/features.rs index 74437f7c998..20d60d17da9 100644 --- a/src/cargo/core/features.rs +++ b/src/cargo/core/features.rs @@ -99,7 +99,7 @@ macro_rules! features { } static FEAT: Feature = Feature { name: stringify!($feature), - get: get, + get, }; &FEAT } diff --git a/src/cargo/core/manifest.rs b/src/cargo/core/manifest.rs index ab90cee0915..0ebe5f533cd 100644 --- a/src/cargo/core/manifest.rs +++ b/src/cargo/core/manifest.rs @@ -275,22 +275,22 @@ impl Manifest { im_a_teapot: Option, original: Rc) -> Manifest { Manifest { - summary: summary, - targets: targets, + summary, + targets, warnings: Vec::new(), - exclude: exclude, - include: include, - links: links, - metadata: metadata, - profiles: profiles, - publish: publish, - replace: replace, - patch: patch, - workspace: workspace, - features: features, - epoch: epoch, - original: original, - im_a_teapot: im_a_teapot, + exclude, + include, + links, + metadata, + profiles, + publish, + replace, + patch, + workspace, + features, + epoch, + original, + im_a_teapot, } } @@ -372,10 +372,10 @@ impl VirtualManifest { workspace: WorkspaceConfig, profiles: Profiles) -> VirtualManifest { VirtualManifest { - replace: replace, - patch: patch, - workspace: workspace, - profiles: profiles, + replace, + patch, + workspace, + profiles, } } @@ -430,7 +430,7 @@ impl Target { Target { kind: TargetKind::Bin, name: name.to_string(), - required_features: required_features, + required_features, doc: true, ..Target::with_path(src_path) } @@ -459,9 +459,9 @@ impl Target { }; Target { - kind: kind, + kind, name: name.to_string(), - required_features: required_features, + required_features, benched: false, ..Target::with_path(src_path) } @@ -472,7 +472,7 @@ impl Target { Target { kind: TargetKind::Test, name: name.to_string(), - required_features: required_features, + required_features, benched: false, ..Target::with_path(src_path) } @@ -483,7 +483,7 @@ impl Target { Target { kind: TargetKind::Bench, name: name.to_string(), - required_features: required_features, + required_features, tested: false, ..Target::with_path(src_path) } diff --git a/src/cargo/core/package.rs b/src/cargo/core/package.rs index e0c54c03af6..252b7ac836e 100644 --- a/src/cargo/core/package.rs +++ b/src/cargo/core/package.rs @@ -58,9 +58,9 @@ impl ser::Serialize for Package { name: package_id.name(), version: &package_id.version().to_string(), id: package_id, - license: license, - license_file: license_file, - description: description, + license, + license_file, + description, source: summary.source_id(), dependencies: summary.dependencies(), targets: self.manifest.targets(), @@ -75,7 +75,7 @@ impl Package { pub fn new(manifest: Manifest, manifest_path: &Path) -> Package { Package { - manifest: manifest, + manifest, manifest_path: manifest_path.to_path_buf(), } } diff --git a/src/cargo/core/package_id.rs b/src/cargo/core/package_id.rs index 90879855581..ffb4330c627 100644 --- a/src/cargo/core/package_id.rs +++ b/src/cargo/core/package_id.rs @@ -64,8 +64,8 @@ impl<'de> de::Deserialize<'de> for PackageId { Ok(PackageId { inner: Arc::new(PackageIdInner { name: name.to_string(), - version: version, - source_id: source_id, + version, + source_id, }), }) } diff --git a/src/cargo/core/package_id_spec.rs b/src/cargo/core/package_id_spec.rs index 318fc0b3ed8..be1170be4a7 100644 --- a/src/cargo/core/package_id_spec.rs +++ b/src/cargo/core/package_id_spec.rs @@ -40,7 +40,7 @@ impl PackageIdSpec { } Ok(PackageIdSpec { name: name.to_string(), - version: version, + version, url: None, }) } @@ -100,8 +100,8 @@ impl PackageIdSpec { } }; Ok(PackageIdSpec { - name: name, - version: version, + name, + version, url: Some(url), }) } diff --git a/src/cargo/core/registry.rs b/src/cargo/core/registry.rs index 1a18bd011e7..051adb84efc 100644 --- a/src/cargo/core/registry.rs +++ b/src/cargo/core/registry.rs @@ -110,7 +110,7 @@ impl<'cfg> PackageRegistry<'cfg> { sources: SourceMap::new(), source_ids: HashMap::new(), overrides: Vec::new(), - source_config: source_config, + source_config, locked: HashMap::new(), patches: HashMap::new(), patches_locked: false, @@ -187,9 +187,9 @@ impl<'cfg> PackageRegistry<'cfg> { trace!("\t-> {}", dep); } let sub_map = self.locked.entry(id.source_id().clone()) - .or_insert(HashMap::new()); + .or_insert_with(HashMap::new); let sub_vec = sub_map.entry(id.name().to_string()) - .or_insert(Vec::new()); + .or_insert_with(Vec::new); sub_vec.push((id, deps)); } diff --git a/src/cargo/core/resolver/encode.rs b/src/cargo/core/resolver/encode.rs index a0cf0bac081..b0f726493d6 100644 --- a/src/cargo/core/resolver/encode.rs +++ b/src/cargo/core/resolver/encode.rs @@ -179,10 +179,10 @@ impl EncodableResolve { graph: g, empty_features: HashSet::new(), features: HashMap::new(), - replacements: replacements, - checksums: checksums, - metadata: metadata, - unused_patches: unused_patches, + replacements, + checksums, + metadata, + unused_patches, }) } } @@ -206,7 +206,7 @@ fn build_path_deps(ws: &Workspace) -> HashMap { for member in members.iter() { build_pkg(member, ws.config(), &mut ret, &mut visited); } - for (_, deps) in ws.root_patch() { + for deps in ws.root_patch().values() { for dep in deps { build_dep(dep, ws.config(), &mut ret, &mut visited); } @@ -372,8 +372,8 @@ impl<'a, 'cfg> ser::Serialize for WorkspaceResolve<'a, 'cfg> { EncodableResolve { package: Some(encodable), root: None, - metadata: metadata, - patch: patch, + metadata, + patch, }.serialize(s) } } @@ -399,7 +399,7 @@ fn encodable_resolve_node(id: &PackageId, resolve: &Resolve) version: id.version().to_string(), source: encode_source(id.source_id()), dependencies: deps, - replace: replace, + replace, } } diff --git a/src/cargo/core/resolver/mod.rs b/src/cargo/core/resolver/mod.rs index e4913268f53..a57695eb1f9 100644 --- a/src/cargo/core/resolver/mod.rs +++ b/src/cargo/core/resolver/mod.rs @@ -540,9 +540,9 @@ enum ConflictReason { impl ConflictReason { fn is_links(&self) -> bool { - match self { - &ConflictReason::Semver => false, - &ConflictReason::Links(_) => true, + match *self { + ConflictReason::Semver => false, + ConflictReason::Links(_) => true, } } } @@ -576,7 +576,11 @@ impl RemainingCandidates { } } - fn next(&mut self, prev_active: &[Summary], links: &HashMap) -> Result<(Candidate, bool), HashMap> { + fn next( + &mut self, + prev_active: &[Summary], + links: &HashMap, + ) -> Result<(Candidate, bool), HashMap> { // Filter the set of candidates based on the previously activated // versions for this dependency. We can actually use a version if it // precisely matches an activated version or if it is otherwise @@ -594,8 +598,10 @@ impl RemainingCandidates { if let Some(link) = b.summary.links() { if let Some(a) = links.get(link) { if a != b.summary.package_id() { - self.conflicting_prev_active.insert(a.clone(), ConflictReason::Links(link.to_owned())); - continue + self.conflicting_prev_active + .entry(a.clone()) + .or_insert_with(|| ConflictReason::Links(link.to_owned())); + continue; } } } @@ -604,7 +610,9 @@ impl RemainingCandidates { .find(|a| compatible(a.version(), b.summary.version())) { if *a != b.summary { - self.conflicting_prev_active.insert(a.package_id().clone(), ConflictReason::Semver); + self.conflicting_prev_active + .entry(a.package_id().clone()) + .or_insert(ConflictReason::Semver); continue; } } @@ -739,7 +747,7 @@ fn activate_deps_loop<'a>( registry, &parent, &dep, - conflicting, + &conflicting, &candidates, config, ) @@ -780,8 +788,8 @@ fn activate_deps_loop<'a>( /// remaining candidates. For each one, also checks if rolling back /// could change the outcome of the failed resolution that caused backtracking /// in the first place. Namely, if we've backtracked past the parent of the -/// failed dep, or any of the packages flagged as giving us trouble in conflicting_activations. -/// Read https://github.com/rust-lang/cargo/pull/4834 +/// failed dep, or any of the packages flagged as giving us trouble in `conflicting_activations`. +/// Read /// For several more detailed explanations of the logic here. /// /// If the outcome could differ, resets `cx` and `remaining_deps` to that @@ -826,7 +834,7 @@ fn activation_error(cx: &Context, registry: &mut Registry, parent: &Summary, dep: &Dependency, - conflicting_activations: HashMap, + conflicting_activations: &HashMap, candidates: &[Candidate], config: Option<&Config>) -> CargoError { let graph = cx.graph(); @@ -860,17 +868,14 @@ fn activation_error(cx: &Context, let (links_errors, other_errors): (Vec<_>, Vec<_>) = conflicting_activations.drain(..).rev().partition(|&(_, r)| r.is_links()); for &(p, r) in &links_errors { - match r { - &ConflictReason::Links(ref link) => { - msg.push_str("\n\nthe package `"); - msg.push_str(dep.name()); - msg.push_str("` links to the native library `"); - msg.push_str(&link); - msg.push_str("`, but it conflicts with a previous package which links to `"); - msg.push_str(&link); - msg.push_str("` as well:\n"); - }, - _ => (), + if let ConflictReason::Links(ref link) = *r { + msg.push_str("\n\nthe package `"); + msg.push_str(dep.name()); + msg.push_str("` links to the native library `"); + msg.push_str(link); + msg.push_str("`, but it conflicts with a previous package which links to `"); + msg.push_str(link); + msg.push_str("` as well:\n"); } msg.push_str(&describe_path(p)); } @@ -1031,7 +1036,7 @@ impl<'r> Requirements<'r> { return Ok(()); } for f in self.summary.features().get(feat).expect("must be a valid feature") { - if f == &feat { + if f == feat { bail!("Cyclic feature dependency: feature `{}` depends on itself", feat); } self.add_feature(f)?; @@ -1095,7 +1100,7 @@ fn build_requirements<'a, 'b: 'a>(s: &'a Summary, method: &'b Method) } Method::Required { uses_default_features: false, .. } => {} } - return Ok(reqs); + Ok(reqs) } impl<'a> Context<'a> { @@ -1110,7 +1115,7 @@ impl<'a> Context<'a> { .entry(id.name().to_string()) .or_insert_with(HashMap::new) .entry(id.source_id().clone()) - .or_insert(Vec::new()); + .or_insert_with(Vec::new); if !prev.iter().any(|c| c == summary) { self.resolve_graph.push(GraphNode::Add(id.clone())); if let Some(link) = summary.links() { @@ -1294,7 +1299,7 @@ impl<'a> Context<'a> { let mut base = base.1; base.extend(dep.features().iter().cloned()); for feature in base.iter() { - if feature.contains("/") { + if feature.contains('/') { bail!("feature names may not contain slashes: `{}`", feature); } } diff --git a/src/cargo/core/shell.rs b/src/cargo/core/shell.rs index a372110cdc9..8ff15611254 100644 --- a/src/cargo/core/shell.rs +++ b/src/cargo/core/shell.rs @@ -27,13 +27,13 @@ pub struct Shell { impl fmt::Debug for Shell { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - match &self.err { - &ShellOut::Write(_) => { + match self.err { + ShellOut::Write(_) => { f.debug_struct("Shell") .field("verbosity", &self.verbosity) .finish() } - &ShellOut::Stream { color_choice, .. } => { + ShellOut::Stream { color_choice, .. } => { f.debug_struct("Shell") .field("verbosity", &self.verbosity) .field("color_choice", &color_choice) @@ -221,6 +221,12 @@ impl Shell { } } +impl Default for Shell { + fn default() -> Self { + Self::new() + } +} + impl ShellOut { /// Print out a message with a status. The status comes first and is bold + the given color. /// The status can be justified, in which case the max width that will right align is 12 chars. diff --git a/src/cargo/core/source/source_id.rs b/src/cargo/core/source/source_id.rs index 1651f530689..2bac7cd015d 100644 --- a/src/cargo/core/source/source_id.rs +++ b/src/cargo/core/source/source_id.rs @@ -70,9 +70,9 @@ impl SourceId { fn new(kind: Kind, url: Url) -> CargoResult { let source_id = SourceId { inner: Arc::new(SourceIdInner { - kind: kind, + kind, canonical_url: git::canonicalize_url(&url)?, - url: url, + url, precise: None, name: None, }), @@ -191,7 +191,7 @@ impl SourceId { inner: Arc::new(SourceIdInner { kind: Kind::Registry, canonical_url: git::canonicalize_url(&url)?, - url: url, + url, precise: None, name: Some(key.to_string()), }), @@ -444,7 +444,7 @@ impl Hash for SourceId { } } -/// A `Display`able view into a SourceId that will write it as a url +/// A `Display`able view into a `SourceId` that will write it as a url pub struct SourceIdToUrl<'a> { inner: &'a SourceIdInner, } @@ -524,6 +524,6 @@ mod tests { let foo = Kind::Git(GitReference::Branch("foo".to_string())); let s3 = SourceId::new(foo, loc).unwrap(); - assert!(s1 != s3); + assert_ne!(s1, s3); } } diff --git a/src/cargo/core/workspace.rs b/src/cargo/core/workspace.rs index 5d21dd8d41a..7a5ef6f3e3f 100644 --- a/src/cargo/core/workspace.rs +++ b/src/cargo/core/workspace.rs @@ -125,14 +125,14 @@ impl<'cfg> Workspace<'cfg> { let target_dir = config.target_dir()?; let mut ws = Workspace { - config: config, + config, current_manifest: manifest_path.to_path_buf(), packages: Packages { - config: config, + config, packages: HashMap::new(), }, root_manifest: None, - target_dir: target_dir, + target_dir, members: Vec::new(), default_members: Vec::new(), is_ephemeral: false, @@ -162,10 +162,10 @@ impl<'cfg> Workspace<'cfg> { target_dir: Option, require_optional_deps: bool) -> CargoResult> { let mut ws = Workspace { - config: config, + config, current_manifest: package.manifest_path().to_path_buf(), packages: Packages { - config: config, + config, packages: HashMap::new(), }, root_manifest: None, @@ -173,7 +173,7 @@ impl<'cfg> Workspace<'cfg> { members: Vec::new(), default_members: Vec::new(), is_ephemeral: true, - require_optional_deps: require_optional_deps, + require_optional_deps, }; { let key = ws.current_manifest.parent().unwrap(); @@ -340,7 +340,7 @@ impl<'cfg> Workspace<'cfg> { match *self.packages.load(&ances_manifest_path)?.workspace_config() { WorkspaceConfig::Root(ref ances_root_config) => { debug!("find_root - found a root checking exclusion"); - if !ances_root_config.is_excluded(&manifest_path) { + if !ances_root_config.is_excluded(manifest_path) { debug!("find_root - found!"); return Ok(Some(ances_manifest_path)) } @@ -443,13 +443,10 @@ impl<'cfg> Workspace<'cfg> { return Ok(()) } - match *self.packages.load(root_manifest)?.workspace_config() { - WorkspaceConfig::Root(ref root_config) => { - if root_config.is_excluded(&manifest_path) { - return Ok(()) - } + if let WorkspaceConfig::Root(ref root_config) = *self.packages.load(root_manifest)?.workspace_config() { + if root_config.is_excluded(&manifest_path) { + return Ok(()) } - _ => {} } debug!("find_members - {}", manifest_path.display()); diff --git a/src/cargo/lib.rs b/src/cargo/lib.rs index ac611b010bc..abcdd3f4adc 100644 --- a/src/cargo/lib.rs +++ b/src/cargo/lib.rs @@ -2,6 +2,11 @@ #![cfg_attr(test, deny(warnings))] #![recursion_limit="128"] +// Currently, Cargo does not use clippy for its source code. +// But if someone runs it they should know that +// @alexcrichton disagree with clippy on some style things +#![cfg_attr(feature = "cargo-clippy", allow(explicit_iter_loop))] + #[macro_use] extern crate failure; #[macro_use] extern crate log; #[macro_use] extern crate scoped_tls; @@ -51,7 +56,7 @@ use core::shell::Verbosity::Verbose; pub use util::{CargoError, CargoResult, CliError, CliResult, Config}; pub use util::errors::Internal; -pub const CARGO_ENV: &'static str = "CARGO"; +pub const CARGO_ENV: &str = "CARGO"; pub mod core; pub mod ops; @@ -232,7 +237,7 @@ pub fn version() -> VersionInfo { pre_release: option_env_str!("CARGO_PKG_VERSION_PRE"), cfg_info: Some(CfgInfo { release_channel: option_env_str!("CFG_RELEASE_CHANNEL").unwrap(), - commit_info: commit_info, + commit_info, }), } }, diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index cc3400268f9..7891ad304e2 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -70,14 +70,14 @@ impl<'a> CompileOptions<'a> { pub fn default(config: &'a Config, mode: CompileMode) -> CompileOptions<'a> { CompileOptions { - config: config, + config, jobs: None, target: None, features: &[], all_features: false, no_default_features: false, spec: ops::Packages::Packages(&[]), - mode: mode, + mode, release: false, filter: CompileFilter::Default { required_features_filterable: false }, message_format: MessageFormat::Human, @@ -321,7 +321,7 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>, config, build_config, profiles, - exec)? + &exec)? }; ret.to_doc_test = to_builds.into_iter().cloned().collect(); @@ -455,7 +455,7 @@ fn generate_auto_targets<'a>(mode: CompileMode, targets: &'a [Target], targets.iter().filter(|t| t.benched()).map(|t| { BuildProposal { target: t, - profile: profile, + profile, required: !required_features_filterable, } }).collect::>() @@ -489,7 +489,7 @@ fn generate_auto_targets<'a>(mode: CompileMode, targets: &'a [Target], t.is_bin() || t.is_lib() }).map(|t| BuildProposal { target: t, - profile: profile, + profile, required: !required_features_filterable, }).collect() } @@ -501,7 +501,7 @@ fn generate_auto_targets<'a>(mode: CompileMode, targets: &'a [Target], ) }).map(|t| BuildProposal { target: t, - profile: profile, + profile, required: !required_features_filterable, }).collect() } @@ -510,7 +510,7 @@ fn generate_auto_targets<'a>(mode: CompileMode, targets: &'a [Target], if t.doctested() { return vec![BuildProposal { target: t, - profile: profile, + profile, required: !required_features_filterable, }]; } @@ -532,7 +532,7 @@ fn propose_indicated_targets<'a>(pkg: &'a Package, let result = pkg.targets().iter().filter(|t| is_expected_kind(t)).map(|t| { BuildProposal { target: t, - profile: profile, + profile, required: false, } }); @@ -561,7 +561,7 @@ fn propose_indicated_targets<'a>(pkg: &'a Package, debug!("found {} `{}`", desc, name); targets.push(BuildProposal { target: t, - profile: profile, + profile, required: true, }); } @@ -650,7 +650,7 @@ fn generate_targets<'a>(pkg: &'a Package, if let Some(t) = pkg.targets().iter().find(|t| t.is_lib()) { targets.push(BuildProposal { target: t, - profile: profile, + profile, required: true, }); } else if !all_targets { @@ -721,7 +721,7 @@ fn scrape_build_config(config: &Config, let mut base = ops::BuildConfig { host_triple: config.rustc()?.host.clone(), requested_target: target.clone(), - jobs: jobs, + jobs, ..Default::default() }; base.host = scrape_target_config(config, &base.host_triple)?; diff --git a/src/cargo/ops/cargo_doc.rs b/src/cargo/ops/cargo_doc.rs index 3a722de2f1e..9f21d1bd69c 100644 --- a/src/cargo/ops/cargo_doc.rs +++ b/src/cargo/ops/cargo_doc.rs @@ -44,13 +44,11 @@ pub fn doc(ws: &Workspace, options: &DocOptions) -> CargoResult<()> { or marking one of the targets as `doc = false`.", target.crate_name(), prev, package); } - } else { - if let Some(prev) = bin_names.insert(target.crate_name(), package) { - bail!("The binary `{}` is specified by packages `{}` and \ - `{}` but can be documented only once. Consider renaming \ - or marking one of the targets as `doc = false`.", - target.crate_name(), prev, package); - } + } else if let Some(prev) = bin_names.insert(target.crate_name(), package) { + bail!("The binary `{}` is specified by packages `{}` and \ + `{}` but can be documented only once. Consider renaming \ + or marking one of the targets as `doc = false`.", + target.crate_name(), prev, package); } } } diff --git a/src/cargo/ops/cargo_generate_lockfile.rs b/src/cargo/ops/cargo_generate_lockfile.rs index 999a758fbaa..d08c11b1662 100644 --- a/src/cargo/ops/cargo_generate_lockfile.rs +++ b/src/cargo/ops/cargo_generate_lockfile.rs @@ -174,10 +174,10 @@ pub fn update_lockfile(ws: &Workspace, opts: &UpdateOptions) let mut changes = BTreeMap::new(); let empty = (Vec::new(), Vec::new()); for dep in previous_resolve.iter() { - changes.entry(key(dep)).or_insert(empty.clone()).0.push(dep); + changes.entry(key(dep)).or_insert_with(||empty.clone()).0.push(dep); } for dep in resolve.iter() { - changes.entry(key(dep)).or_insert(empty.clone()).1.push(dep); + changes.entry(key(dep)).or_insert_with(||empty.clone()).1.push(dep); } for v in changes.values_mut() { diff --git a/src/cargo/ops/cargo_install.rs b/src/cargo/ops/cargo_install.rs index c85923e453b..f3cbdac4524 100644 --- a/src/cargo/ops/cargo_install.rs +++ b/src/cargo/ops/cargo_install.rs @@ -286,7 +286,7 @@ fn install_one(root: &Filesystem, } } list.v1.entry(pkg.package_id().clone()) - .or_insert_with(|| BTreeSet::new()) + .or_insert_with(BTreeSet::new) .insert(bin.to_string()); } @@ -301,7 +301,7 @@ fn install_one(root: &Filesystem, // If installation was successful record newly installed binaries. if result.is_ok() { list.v1.entry(pkg.package_id().clone()) - .or_insert_with(|| BTreeSet::new()) + .or_insert_with(BTreeSet::new) .extend(to_install.iter().map(|s| s.to_string())); } @@ -347,7 +347,7 @@ fn select_pkg<'a, T>(mut source: T, // version range, otherwise parse it as a specific version let first = v.chars() .nth(0) - .ok_or(format_err!("no version provided for the `--vers` flag"))?; + .ok_or_else(||format_err!("no version provided for the `--vers` flag"))?; match first { '<' | '>' | '=' | '^' | '~' => match v.parse::() { @@ -570,20 +570,20 @@ pub fn uninstall(root: Option<&str>, specs: Vec<&str>, bins: &[String], config: &Config) -> CargoResult<()> { - if specs.len() > 1 && bins.len() > 0 { + if specs.len() > 1 && !bins.is_empty() { bail!("A binary can only be associated with a single installed package, specifying multiple specs with --bin is redundant."); } let root = resolve_root(root, config)?; let scheduled_error = if specs.len() == 1 { - uninstall_one(root, specs[0], bins, config)?; + uninstall_one(&root, specs[0], bins, config)?; false } else { let mut succeeded = vec![]; let mut failed = vec![]; for spec in specs { let root = root.clone(); - match uninstall_one(root, spec, bins, config) { + match uninstall_one(&root, spec, bins, config) { Ok(()) => succeeded.push(spec), Err(e) => { ::handle_error(e, &mut config.shell()); @@ -614,11 +614,11 @@ pub fn uninstall(root: Option<&str>, Ok(()) } -pub fn uninstall_one(root: Filesystem, +pub fn uninstall_one(root: &Filesystem, spec: &str, bins: &[String], config: &Config) -> CargoResult<()> { - let crate_metadata = metadata(config, &root)?; + let crate_metadata = metadata(config, root)?; let mut metadata = read_crate_list(&crate_metadata)?; let mut to_remove = Vec::new(); { diff --git a/src/cargo/ops/cargo_new.rs b/src/cargo/ops/cargo_new.rs index aaaa69e2176..fa370b47c38 100644 --- a/src/cargo/ops/cargo_new.rs +++ b/src/cargo/ops/cargo_new.rs @@ -90,10 +90,9 @@ impl<'a> NewOptions<'a> { let kind = match (bin, lib) { (true, true) => bail!("can't specify both lib and binary outputs"), - (true, false) => NewProjectKind::Bin, (false, true) => NewProjectKind::Lib, // default to bin - (false, false) => NewProjectKind::Bin, + (_, false) => NewProjectKind::Bin, }; let opts = NewOptions { version_control, kind, path, name }; @@ -291,7 +290,7 @@ pub fn new(opts: &NewOptions, config: &Config) -> CargoResult<()> { let mkopts = MkOptions { version_control: opts.version_control, path: &path, - name: name, + name, source_files: vec![plan_new_source_file(opts.kind.is_bin(), name.to_string())], bin: opts.kind.is_bin(), }; @@ -580,8 +579,8 @@ fn global_config(config: &Config) -> CargoResult { None => None }; Ok(CargoNewConfig { - name: name, - email: email, + name, + email, version_control: vcs, }) } diff --git a/src/cargo/ops/cargo_output_metadata.rs b/src/cargo/ops/cargo_output_metadata.rs index 1b6da788f20..0e44252547c 100644 --- a/src/cargo/ops/cargo_output_metadata.rs +++ b/src/cargo/ops/cargo_output_metadata.rs @@ -59,10 +59,10 @@ fn metadata_full(ws: &Workspace, .collect::>>()?; Ok(ExportInfo { - packages: packages, + packages, workspace_members: ws.members().map(|pkg| pkg.package_id().clone()).collect(), resolve: Some(MetadataResolve{ - resolve: resolve, + resolve, root: ws.current_opt().map(|pkg| pkg.package_id().clone()), }), target_directory: ws.target_dir().display().to_string(), @@ -102,7 +102,7 @@ fn serialize_resolve(resolve: &Resolve, s: S) -> Result resolve.iter().map(|id| { Node { - id: id, + id, dependencies: resolve.deps(id).collect(), } }).collect::>().serialize(s) diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs index 9562b7abae5..0dc3aedd5dc 100644 --- a/src/cargo/ops/cargo_package.rs +++ b/src/cargo/ops/cargo_package.rs @@ -292,7 +292,7 @@ fn run_verify(ws: &Workspace, tar: &FileLock, opts: &PackageOpts) -> CargoResult let ws = Workspace::ephemeral(new_pkg, config, None, true)?; ops::compile_ws(&ws, None, &ops::CompileOptions { - config: config, + config, jobs: opts.jobs, target: opts.target, features: &[], diff --git a/src/cargo/ops/cargo_read_manifest.rs b/src/cargo/ops/cargo_read_manifest.rs index 48c2d9dabe1..13ce7affd60 100644 --- a/src/cargo/ops/cargo_read_manifest.rs +++ b/src/cargo/ops/cargo_read_manifest.rs @@ -138,11 +138,13 @@ fn read_nested_packages(path: &Path, let pkg = Package::new(manifest, &manifest_path); let pkg_id = pkg.package_id().clone(); - if !all_packages.contains_key(&pkg_id) { - all_packages.insert(pkg_id, pkg); - } else { - info!("skipping nested package `{}` found at `{}`", - pkg.name(), path.to_string_lossy()); + use ::std::collections::hash_map::Entry; + match all_packages.entry(pkg_id) { + Entry::Vacant(v) => { v.insert(pkg); }, + Entry::Occupied(_) => { + info!("skipping nested package `{}` found at `{}`", + pkg.name(), path.to_string_lossy()); + } } // Registry sources are not allowed to have `path=` dependencies because diff --git a/src/cargo/ops/cargo_run.rs b/src/cargo/ops/cargo_run.rs index ff3c46b5669..81ac7790844 100644 --- a/src/cargo/ops/cargo_run.rs +++ b/src/cargo/ops/cargo_run.rs @@ -34,7 +34,7 @@ pub fn run(ws: &Workspace, .map(|bin| bin.name()) .collect(); - if bins.len() == 0 { + if bins.is_empty() { if !options.filter.is_specific() { bail!("a bin target must be available for `cargo run`") } else { diff --git a/src/cargo/ops/cargo_rustc/compilation.rs b/src/cargo/ops/cargo_rustc/compilation.rs index 88f82516bd4..7cb781e0f2d 100644 --- a/src/cargo/ops/cargo_rustc/compilation.rs +++ b/src/cargo/ops/cargo_rustc/compilation.rs @@ -80,7 +80,7 @@ impl<'cfg> Compilation<'cfg> { to_doc_test: Vec::new(), cfgs: HashMap::new(), rustdocflags: HashMap::new(), - config: config, + config, target: String::new(), target_runner: LazyCell::new(), } diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index 325d7434637..a23e9fe03d0 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -175,26 +175,26 @@ impl<'a, 'cfg> Context<'a, 'cfg> { }; Ok(Context { - ws: ws, + ws, host: host_layout, target: target_layout, - resolve: resolve, - packages: packages, - config: config, + resolve, + packages, + config, target_info: TargetInfo::default(), host_info: TargetInfo::default(), compilation: Compilation::new(config), build_state: Arc::new(BuildState::new(&build_config)), - build_config: build_config, + build_config, fingerprints: HashMap::new(), - profiles: profiles, + profiles, compiled: HashSet::new(), build_scripts: HashMap::new(), build_explicit_deps: HashMap::new(), links: Links::new(), used_in_plugin: HashSet::new(), incremental_env, - jobserver: jobserver, + jobserver, build_script_overridden: HashSet::new(), // TODO: Pre-Calculate these with a topo-sort, rather than lazy-calculating @@ -346,7 +346,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { } let cfg = if has_cfg_and_sysroot { - Some(try!(lines.map(Cfg::from_str).collect())) + Some(lines.map(Cfg::from_str).collect::>()?) } else { None }; @@ -471,7 +471,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { /// Return the target triple which this context is targeting. pub fn target_triple(&self) -> &str { - self.requested_target().unwrap_or(self.host_triple()) + self.requested_target().unwrap_or_else(|| self.host_triple()) } /// Requested (not actual) target for the build @@ -694,8 +694,8 @@ impl<'a, 'cfg> Context<'a, 'cfg> { match *crate_type_info { Some((ref prefix, ref suffix)) => { let suffixes = add_target_specific_suffixes( - &self.target_triple(), - &crate_type, + self.target_triple(), + crate_type, unit.target.kind(), suffix, file_type, @@ -819,7 +819,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { Ok(pkg) => { pkg.targets().iter().find(|t| t.is_lib()).map(|t| { let unit = Unit { - pkg: pkg, + pkg, target: t, profile: self.lib_or_check_profile(unit, t), kind: unit.kind.for_target(t), @@ -1055,10 +1055,9 @@ impl<'a, 'cfg> Context<'a, 'cfg> { } pub fn lib_or_check_profile(&self, unit: &Unit, target: &Target) -> &'a Profile { - if !target.is_custom_build() && !target.for_host() { - if unit.profile.check || (unit.profile.doc && !unit.profile.test) { + if !target.is_custom_build() && !target.for_host() + && (unit.profile.check || (unit.profile.doc && !unit.profile.test)) { return &self.profiles.check - } } self.lib_profile() } diff --git a/src/cargo/ops/cargo_rustc/custom_build.rs b/src/cargo/ops/cargo_rustc/custom_build.rs index 95940bfcb13..a7f3160ae2d 100644 --- a/src/cargo/ops/cargo_rustc/custom_build.rs +++ b/src/cargo/ops/cargo_rustc/custom_build.rs @@ -145,9 +145,8 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) match *cfg { Cfg::Name(ref n) => { cfg_map.insert(n.clone(), None); } Cfg::KeyPair(ref k, ref v) => { - match *cfg_map.entry(k.clone()).or_insert(Some(Vec::new())) { - Some(ref mut values) => values.push(v.clone()), - None => { /* ... */ } + if let Some(ref mut values) = *cfg_map.entry(k.clone()).or_insert_with(||Some(Vec::new())) { + values.push(v.clone()) } } } @@ -196,7 +195,7 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) // track of whether it has told us about some explicit dependencies let prev_root_output = paths::read_bytes(&root_output_file) .and_then(|bytes| util::bytes2path(&bytes)) - .unwrap_or(cmd.get_cwd().unwrap().to_path_buf()); + .unwrap_or_else(|_| cmd.get_cwd().unwrap().to_path_buf()); let prev_output = BuildOutput::parse_file( &output_file, &pkg_name, @@ -273,7 +272,7 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) // well. paths::write(&output_file, &output.stdout)?; paths::write(&err_file, &output.stderr)?; - paths::write(&root_output_file, &util::path2bytes(&root_output)?)?; + paths::write(&root_output_file, util::path2bytes(&root_output)?)?; let parsed_output = BuildOutput::parse( &output.stdout, &pkg_name, @@ -331,7 +330,7 @@ impl BuildState { } BuildState { outputs: Mutex::new(HashMap::new()), - overrides: overrides, + overrides, } } @@ -416,14 +415,14 @@ impl BuildOutput { } Ok(BuildOutput { - library_paths: library_paths, - library_links: library_links, - cfgs: cfgs, - env: env, - metadata: metadata, - rerun_if_changed: rerun_if_changed, - rerun_if_env_changed: rerun_if_env_changed, - warnings: warnings, + library_paths, + library_links, + cfgs, + env, + metadata, + rerun_if_changed, + rerun_if_env_changed, + warnings, }) } @@ -553,7 +552,7 @@ pub fn build_map<'b, 'cfg>(cx: &mut Context<'b, 'cfg>, } } - let prev = out.entry(*unit).or_insert(BuildScripts::default()); + let prev = out.entry(*unit).or_insert_with(BuildScripts::default); for (pkg, kind) in ret.to_link { add_to_link(prev, &pkg, kind); } diff --git a/src/cargo/ops/cargo_rustc/fingerprint.rs b/src/cargo/ops/cargo_rustc/fingerprint.rs index 3080cee3dda..c9ef8f24597 100644 --- a/src/cargo/ops/cargo_rustc/fingerprint.rs +++ b/src/cargo/ops/cargo_rustc/fingerprint.rs @@ -319,9 +319,9 @@ impl hash::Hash for Fingerprint { profile, ref deps, ref local, - memoized_hash: _, epoch, ref rustflags, + .. } = *self; (rustc, features, target, path, profile, local, epoch, rustflags).hash(h); @@ -419,7 +419,7 @@ fn calculate<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) // actually affect the output artifact so there's no need to hash it. path: util::hash_u64(&super::path_args(cx, unit).0), features: format!("{:?}", cx.resolve.features_sorted(unit.pkg.package_id())), - deps: deps, + deps, local: vec![local], memoized_hash: Mutex::new(None), epoch: unit.pkg.manifest().epoch(), @@ -473,7 +473,7 @@ pub fn prepare_build_cmd<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) path: 0, features: String::new(), deps: Vec::new(), - local: local, + local, memoized_hash: Mutex::new(None), epoch: Epoch::Epoch2015, rustflags: Vec::new(), @@ -632,7 +632,7 @@ pub fn parse_dep_info(pkg: &Package, dep_info: &Path) .filter(|x| !x.is_empty()) .map(|p| util::bytes2path(p).map(|p| pkg.root().join(p))) .collect::, _>>()?; - if paths.len() == 0 { + if paths.is_empty() { Ok(None) } else { Ok(Some(paths)) diff --git a/src/cargo/ops/cargo_rustc/job.rs b/src/cargo/ops/cargo_rustc/job.rs index 219a6d43749..cb49d07d8df 100644 --- a/src/cargo/ops/cargo_rustc/job.rs +++ b/src/cargo/ops/cargo_rustc/job.rs @@ -47,7 +47,7 @@ impl Work { impl Job { /// Create a new job representing a unit of work. pub fn new(dirty: Work, fresh: Work) -> Job { - Job { dirty: dirty, fresh: fresh } + Job { dirty, fresh } } /// Consumes this job by running it, returning the result of the diff --git a/src/cargo/ops/cargo_rustc/job_queue.rs b/src/cargo/ops/cargo_rustc/job_queue.rs index 281f057aba1..6613404cd99 100644 --- a/src/cargo/ops/cargo_rustc/job_queue.rs +++ b/src/cargo/ops/cargo_rustc/job_queue.rs @@ -81,8 +81,8 @@ impl<'a> JobQueue<'a> { let (tx, rx) = channel(); JobQueue { queue: DependencyQueue::new(), - tx: tx, - rx: rx, + tx, + rx, active: 0, pending: HashMap::new(), compiled: HashSet::new(), diff --git a/src/cargo/ops/cargo_rustc/layout.rs b/src/cargo/ops/cargo_rustc/layout.rs index c5a6b875daa..23a7490d9c2 100644 --- a/src/cargo/ops/cargo_rustc/layout.rs +++ b/src/cargo/ops/cargo_rustc/layout.rs @@ -117,7 +117,7 @@ impl Layout { incremental: root.join("incremental"), fingerprint: root.join(".fingerprint"), examples: root.join("examples"), - root: root, + root, _lock: lock, }) } diff --git a/src/cargo/ops/cargo_rustc/links.rs b/src/cargo/ops/cargo_rustc/links.rs index 5484a68b9a3..06461a46bf9 100644 --- a/src/cargo/ops/cargo_rustc/links.rs +++ b/src/cargo/ops/cargo_rustc/links.rs @@ -5,6 +5,7 @@ use core::{Resolve, PackageId}; use util::CargoResult; use super::Unit; +#[derive(Default)] pub struct Links<'a> { validated: HashSet<&'a PackageId>, links: HashMap, diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index ec97e81b2cc..5a05d45a6f4 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -139,7 +139,7 @@ pub fn compile_targets<'a, 'cfg: 'a>(ws: &Workspace<'cfg>, config: &'cfg Config, build_config: BuildConfig, profiles: &'a Profiles, - exec: Arc) + exec: &Arc) -> CargoResult> { let units = pkg_targets.iter().flat_map(|&(pkg, ref targets)| { let default_kind = if build_config.requested_target.is_some() { @@ -149,9 +149,9 @@ pub fn compile_targets<'a, 'cfg: 'a>(ws: &Workspace<'cfg>, }; targets.iter().map(move |&(target, profile)| { Unit { - pkg: pkg, - target: target, - profile: profile, + pkg, + target, + profile, kind: if target.for_host() {Kind::Host} else {default_kind}, } }) @@ -173,7 +173,7 @@ pub fn compile_targets<'a, 'cfg: 'a>(ws: &Workspace<'cfg>, // part of this, that's all done next as part of the `execute` // function which will run everything in order with proper // parallelism. - compile(&mut cx, &mut queue, unit, Arc::clone(&exec))?; + compile(&mut cx, &mut queue, unit, exec)?; } // Now that we've figured out everything that we're going to do, do it! @@ -199,7 +199,7 @@ pub fn compile_targets<'a, 'cfg: 'a>(ws: &Workspace<'cfg>, cx.compilation.binaries.push(bindst.clone()); } else if unit.target.is_lib() { let pkgid = unit.pkg.package_id().clone(); - cx.compilation.libraries.entry(pkgid).or_insert(HashSet::new()) + cx.compilation.libraries.entry(pkgid).or_insert_with(HashSet::new) .insert((unit.target.clone(), dst.clone())); } } @@ -210,7 +210,7 @@ pub fn compile_targets<'a, 'cfg: 'a>(ws: &Workspace<'cfg>, if dep.profile.run_custom_build { let out_dir = cx.build_script_out_dir(dep).display().to_string(); cx.compilation.extra_env.entry(dep.pkg.package_id().clone()) - .or_insert(Vec::new()) + .or_insert_with(Vec::new) .push(("OUT_DIR".to_string(), out_dir)); } @@ -220,7 +220,7 @@ pub fn compile_targets<'a, 'cfg: 'a>(ws: &Workspace<'cfg>, let v = cx.target_filenames(dep)?; cx.compilation.libraries .entry(unit.pkg.package_id().clone()) - .or_insert(HashSet::new()) + .or_insert_with(HashSet::new) .extend(v.iter().map(|&(ref f, _, _)| { (dep.target.clone(), f.clone()) })); @@ -232,7 +232,7 @@ pub fn compile_targets<'a, 'cfg: 'a>(ws: &Workspace<'cfg>, feats.iter().map(|feat| format!("feature=\"{}\"", feat)).collect() }); } - let rustdocflags = cx.rustdocflags_args(&unit)?; + let rustdocflags = cx.rustdocflags_args(unit)?; if !rustdocflags.is_empty() { cx.compilation.rustdocflags.entry(unit.pkg.package_id().clone()) .or_insert(rustdocflags); @@ -261,7 +261,7 @@ pub fn compile_targets<'a, 'cfg: 'a>(ws: &Workspace<'cfg>, fn compile<'a, 'cfg: 'a>(cx: &mut Context<'a, 'cfg>, jobs: &mut JobQueue<'a>, unit: &Unit<'a>, - exec: Arc) -> CargoResult<()> { + exec: &Arc) -> CargoResult<()> { if !cx.compiled.insert(*unit) { return Ok(()) } @@ -283,7 +283,7 @@ fn compile<'a, 'cfg: 'a>(cx: &mut Context<'a, 'cfg>, let work = if unit.profile.doc { rustdoc(cx, unit)? } else { - rustc(cx, unit, Arc::clone(&exec))? + rustc(cx, unit, exec)? }; // Need to link targets on both the dirty and fresh let dirty = work.then(link_targets(cx, unit, false)?).then(dirty); @@ -300,7 +300,7 @@ fn compile<'a, 'cfg: 'a>(cx: &mut Context<'a, 'cfg>, // Be sure to compile all dependencies of this target as well. for unit in cx.dep_targets(unit)?.iter() { - compile(cx, jobs, unit, exec.clone())?; + compile(cx, jobs, unit, exec)?; } Ok(()) @@ -308,7 +308,7 @@ fn compile<'a, 'cfg: 'a>(cx: &mut Context<'a, 'cfg>, fn rustc<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>, - exec: Arc) -> CargoResult { + exec: &Arc) -> CargoResult { let mut rustc = prepare_rustc(cx, &unit.target.rustc_crate_types(), unit)?; let name = unit.pkg.name().to_string(); @@ -359,7 +359,7 @@ fn rustc<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, let root_output = cx.target_root().to_path_buf(); let pkg_root = unit.pkg.root().to_path_buf(); - let cwd = rustc.get_cwd().unwrap_or(cx.config.cwd()).to_path_buf(); + let cwd = rustc.get_cwd().unwrap_or_else(|| cx.config.cwd()).to_path_buf(); return Ok(Work::new(move |state| { // Only at runtime have we discovered what the extra -L and -l @@ -576,9 +576,9 @@ fn link_targets<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, package_id: &package_id, target: &target, profile: &profile, - features: features, + features, filenames: destinations, - fresh: fresh, + fresh, }); } Ok(()) @@ -747,7 +747,7 @@ fn build_base_args<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, let Profile { ref opt_level, ref lto, codegen_units, ref rustc_args, debuginfo, debug_assertions, overflow_checks, rpath, test, doc: _doc, - run_custom_build, ref panic, rustdoc_args: _, check, incremental: _, + run_custom_build, ref panic, check, .. } = *unit.profile; assert!(!run_custom_build); @@ -935,8 +935,7 @@ fn build_deps_args<'a, 'cfg>(cmd: &mut ProcessBuilder, // error in the future, see PR #4797 if !dep_targets.iter().any(|u| !u.profile.doc && u.target.linkable()) { if let Some(u) = dep_targets.iter() - .filter(|u| !u.profile.doc && u.target.is_lib()) - .next() { + .find(|u| !u.profile.doc && u.target.is_lib()) { cx.config.shell().warn(format!("The package `{}` \ provides no linkable target. The compiler might raise an error while compiling \ `{}`. Consider adding 'dylib' or 'rlib' to key `crate-type` in `{}`'s \ @@ -952,7 +951,7 @@ Cargo.toml. This warning might turn into a hard error in the future.", cmd.env("OUT_DIR", &cx.build_script_out_dir(&dep)); } if dep.target.linkable() && !dep.profile.doc { - link_to(cmd, cx, &unit, &dep)?; + link_to(cmd, cx, unit, &dep)?; } } diff --git a/src/cargo/ops/registry.rs b/src/cargo/ops/registry.rs index daf80a6241e..fb776d61bf8 100644 --- a/src/cargo/ops/registry.rs +++ b/src/cargo/ops/registry.rs @@ -48,7 +48,7 @@ pub fn publish(ws: &Workspace, opts: &PublishOpts) -> CargoResult<()> { bail!("cannot publish crates which activate nightly-only cargo features to crates.io") } - if let &Some(ref allowed_registries) = pkg.publish() { + if let Some(ref allowed_registries) = *pkg.publish() { if !match opts.registry { Some(ref registry) => allowed_registries.contains(registry), None => false, @@ -180,7 +180,7 @@ fn transmit(config: &Config, let publish = registry.publish(&NewCrate { name: pkg.name().to_string(), vers: pkg.version().to_string(), - deps: deps, + deps, features: pkg.summary().features().clone(), authors: authors.clone(), description: description.clone(), @@ -241,8 +241,8 @@ pub fn registry_configuration(config: &Config, }; Ok(RegistryConfig { - index: index, - token: token + index, + token }) } diff --git a/src/cargo/ops/resolve.rs b/src/cargo/ops/resolve.rs index 8a49de85dc4..a4c754c3fc1 100644 --- a/src/cargo/ops/resolve.rs +++ b/src/cargo/ops/resolve.rs @@ -234,7 +234,7 @@ pub fn resolve_with_previous<'a>(registry: &mut PackageRegistry, // for any other packages specified with `-p`. Method::Required { dev_deps, .. } => { let base = Method::Required { - dev_deps: dev_deps, + dev_deps, features: &[], uses_default_features: true, }; diff --git a/src/cargo/sources/config.rs b/src/cargo/sources/config.rs index 98361ddf03a..5db68efd5b3 100644 --- a/src/cargo/sources/config.rs +++ b/src/cargo/sources/config.rs @@ -56,7 +56,7 @@ impl<'cfg> SourceConfigMap<'cfg> { let mut base = SourceConfigMap { cfgs: HashMap::new(), id2name: HashMap::new(), - config: config, + config, }; base.add("crates-io", SourceConfig { id: SourceId::crates_io(config)?, @@ -208,7 +208,7 @@ restore the source replacement configuration to continue the build self.add(name, SourceConfig { id: src, - replace_with: replace_with, + replace_with, }); return Ok(()); diff --git a/src/cargo/sources/directory.rs b/src/cargo/sources/directory.rs index 04df0a5ba62..97cf4242d0a 100644 --- a/src/cargo/sources/directory.rs +++ b/src/cargo/sources/directory.rs @@ -33,7 +33,7 @@ impl<'cfg> DirectorySource<'cfg> { DirectorySource { source_id: id.clone(), root: path.to_path_buf(), - config: config, + config, packages: HashMap::new(), } } diff --git a/src/cargo/sources/git/source.rs b/src/cargo/sources/git/source.rs index 0ec9c169778..6d3d878a69e 100644 --- a/src/cargo/sources/git/source.rs +++ b/src/cargo/sources/git/source.rs @@ -37,13 +37,13 @@ impl<'cfg> GitSource<'cfg> { }; let source = GitSource { - remote: remote, - reference: reference, + remote, + reference, source_id: source_id.clone(), path_source: None, rev: None, - ident: ident, - config: config, + ident, + config, }; Ok(source) diff --git a/src/cargo/sources/git/utils.rs b/src/cargo/sources/git/utils.rs index 1f395012bec..1958500dff9 100644 --- a/src/cargo/sources/git/utils.rs +++ b/src/cargo/sources/git/utils.rs @@ -109,7 +109,7 @@ impl GitRemote { Ok(GitDatabase { remote: self.clone(), path: into.to_path_buf(), - repo: repo, + repo, }) } @@ -118,7 +118,7 @@ impl GitRemote { Ok(GitDatabase { remote: self.clone(), path: db_path.to_path_buf(), - repo: repo, + repo, }) } @@ -210,9 +210,9 @@ impl<'a> GitCheckout<'a> { { GitCheckout { location: path.to_path_buf(), - database: database, - revision: revision, - repo: repo, + database, + revision, + repo, } } diff --git a/src/cargo/sources/path.rs b/src/cargo/sources/path.rs index 9148ccb0f89..f24909ef929 100644 --- a/src/cargo/sources/path.rs +++ b/src/cargo/sources/path.rs @@ -34,7 +34,7 @@ impl<'cfg> PathSource<'cfg> { path: path.to_path_buf(), updated: false, packages: Vec::new(), - config: config, + config, recursive: false, } } @@ -452,7 +452,8 @@ impl<'cfg> PathSource<'cfg> { // Skip dotfile directories if name.map(|s| s.starts_with('.')) == Some(true) { continue - } else if is_root { + } + if is_root { // Skip cargo artifacts match name { Some("target") | Some("Cargo.lock") => continue, diff --git a/src/cargo/sources/registry/index.rs b/src/cargo/sources/registry/index.rs index 710c8ac8982..d3135bac365 100644 --- a/src/cargo/sources/registry/index.rs +++ b/src/cargo/sources/registry/index.rs @@ -31,8 +31,8 @@ impl<'cfg> RegistryIndex<'cfg> { path: path.clone(), cache: HashMap::new(), hashes: HashMap::new(), - config: config, - locked: locked, + config, + locked, } } diff --git a/src/cargo/sources/registry/local.rs b/src/cargo/sources/registry/local.rs index d4d67a229b3..73f6f719bae 100644 --- a/src/cargo/sources/registry/local.rs +++ b/src/cargo/sources/registry/local.rs @@ -25,7 +25,7 @@ impl<'cfg> LocalRegistry<'cfg> { src_path: config.registry_source_path().join(name), index_path: Filesystem::new(root.join("index")), root: Filesystem::new(root.to_path_buf()), - config: config, + config, } } } diff --git a/src/cargo/sources/registry/mod.rs b/src/cargo/sources/registry/mod.rs index e7edf91f169..319f2a9dd6a 100644 --- a/src/cargo/sources/registry/mod.rs +++ b/src/cargo/sources/registry/mod.rs @@ -177,10 +177,10 @@ use util::errors::CargoResultExt; use util::hex; use util::to_url::ToUrl; -const INDEX_LOCK: &'static str = ".cargo-index-lock"; -pub const CRATES_IO: &'static str = "https://github.com/rust-lang/crates.io-index"; -const CRATE_TEMPLATE: &'static str = "{crate}"; -const VERSION_TEMPLATE: &'static str = "{version}"; +const INDEX_LOCK: &str = ".cargo-index-lock"; +pub const CRATES_IO: &str = "https://github.com/rust-lang/crates.io-index"; +const CRATE_TEMPLATE: &str = "{crate}"; +const VERSION_TEMPLATE: &str = "{version}"; pub struct RegistrySource<'cfg> { source_id: SourceId, @@ -288,15 +288,15 @@ impl<'cfg> RegistrySource<'cfg> { index_locked: bool) -> RegistrySource<'cfg> { RegistrySource { src_path: config.registry_source_path().join(name), - config: config, + config, source_id: source_id.clone(), updated: false, index: index::RegistryIndex::new(source_id, ops.index_path(), config, index_locked), - index_locked: index_locked, - ops: ops, + index_locked, + ops, } } diff --git a/src/cargo/sources/registry/remote.rs b/src/cargo/sources/registry/remote.rs index ecaaf976778..1432c6a33fc 100644 --- a/src/cargo/sources/registry/remote.rs +++ b/src/cargo/sources/registry/remote.rs @@ -36,7 +36,7 @@ impl<'cfg> RemoteRegistry<'cfg> { index_path: config.registry_index_path().join(name), cache_path: config.registry_cache_path().join(name), source_id: source_id.clone(), - config: config, + config, tree: RefCell::new(None), repo: LazyCell::new(), head: Cell::new(None), diff --git a/src/cargo/util/config.rs b/src/cargo/util/config.rs index 8d1d75e8613..588ad3592f2 100644 --- a/src/cargo/util/config.rs +++ b/src/cargo/util/config.rs @@ -84,7 +84,7 @@ impl Config { home_path: Filesystem::new(homedir), shell: RefCell::new(shell), rustc: LazyCell::new(), - cwd: cwd, + cwd, values: LazyCell::new(), cargo_exe: LazyCell::new(), rustdoc: LazyCell::new(), diff --git a/src/cargo/util/errors.rs b/src/cargo/util/errors.rs index 565b41bb4c7..e552069d034 100644 --- a/src/cargo/util/errors.rs +++ b/src/cargo/util/errors.rs @@ -104,8 +104,8 @@ impl CargoTestError { .collect::>() .join("\n"); CargoTestError { - test: test, - desc: desc, + test, + desc, exit: errors[0].exit, causes: errors, } @@ -201,7 +201,7 @@ pub fn process_error(msg: &str, } return ProcessError { - desc: desc, + desc, exit: status.cloned(), output: output.cloned(), }; diff --git a/src/cargo/util/flock.rs b/src/cargo/util/flock.rs index 2913d436310..28e7206372a 100644 --- a/src/cargo/util/flock.rs +++ b/src/cargo/util/flock.rs @@ -17,7 +17,7 @@ pub struct FileLock { state: State, } -#[derive(PartialEq)] +#[derive(PartialEq, Debug)] enum State { Unlocked, Shared, @@ -35,13 +35,13 @@ impl FileLock { /// Note that special care must be taken to ensure that the path is not /// referenced outside the lifetime of this lock. pub fn path(&self) -> &Path { - assert!(self.state != State::Unlocked); + assert_ne!(self.state, State::Unlocked); &self.path } /// Returns the parent path containing this file pub fn parent(&self) -> &Path { - assert!(self.state != State::Unlocked); + assert_ne!(self.state, State::Unlocked); self.path.parent().unwrap() } @@ -229,7 +229,7 @@ impl Filesystem { State::Unlocked => {} } - Ok(FileLock { f: Some(f), path: path, state: state }) + Ok(FileLock { f: Some(f), path, state }) } } diff --git a/src/cargo/util/job.rs b/src/cargo/util/job.rs index 42035e1713f..c9f1bef632a 100644 --- a/src/cargo/util/job.rs +++ b/src/cargo/util/job.rs @@ -114,7 +114,7 @@ mod imp { return None } - Some(Setup { job: job }) + Some(Setup { job }) } impl Drop for Setup { @@ -257,7 +257,7 @@ mod imp { killed = true; } - return killed + killed } } diff --git a/src/cargo/util/paths.rs b/src/cargo/util/paths.rs index 90fdb978a68..c2d290182c7 100644 --- a/src/cargo/util/paths.rs +++ b/src/cargo/util/paths.rs @@ -20,7 +20,7 @@ pub fn join_paths>(paths: &[T], env: &str) -> CargoResult &'static str { diff --git a/src/cargo/util/process_builder.rs b/src/cargo/util/process_builder.rs index 8082369d9d5..6fe6d7b9a65 100644 --- a/src/cargo/util/process_builder.rs +++ b/src/cargo/util/process_builder.rs @@ -244,9 +244,9 @@ impl ProcessBuilder { None) })?; let output = Output { - stdout: stdout, - stderr: stderr, - status: status, + stdout, + stderr, + status, }; { @@ -305,7 +305,7 @@ impl ProcessBuilder { } } -/// A helper function to create a ProcessBuilder. +/// A helper function to create a `ProcessBuilder`. pub fn process>(cmd: T) -> ProcessBuilder { ProcessBuilder { program: cmd.as_ref().to_os_string(), diff --git a/src/cargo/util/read2.rs b/src/cargo/util/read2.rs index 7b268108296..ba8b2b58d46 100644 --- a/src/cargo/util/read2.rs +++ b/src/cargo/util/read2.rs @@ -137,7 +137,7 @@ mod imp { impl<'a> Pipe<'a> { unsafe fn new(p: P, dst: &'a mut Vec) -> Pipe<'a> { Pipe { - dst: dst, + dst, pipe: NamedPipe::from_raw_handle(p.into_raw_handle()), overlapped: Overlapped::zero(), done: false, diff --git a/src/cargo/util/rustc.rs b/src/cargo/util/rustc.rs index a9b65c959ca..fdd96748c0c 100644 --- a/src/cargo/util/rustc.rs +++ b/src/cargo/util/rustc.rs @@ -40,10 +40,10 @@ impl Rustc { }; Ok(Rustc { - path: path, - wrapper: wrapper, - verbose_version: verbose_version, - host: host, + path, + wrapper, + verbose_version, + host, }) } diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index 7fc975a0a7d..3e1878853a7 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -301,22 +301,22 @@ impl<'de> de::Deserialize<'de> for U32OrBool { formatter.write_str("a boolean or an integer") } - fn visit_i64(self, u: i64) -> Result + fn visit_bool(self, b: bool) -> Result where E: de::Error, { - Ok(U32OrBool::U32(u as u32)) + Ok(U32OrBool::Bool(b)) } - fn visit_u64(self, u: u64) -> Result + fn visit_i64(self, u: i64) -> Result where E: de::Error, { Ok(U32OrBool::U32(u as u32)) } - fn visit_bool(self, b: bool) -> Result + fn visit_u64(self, u: u64) -> Result where E: de::Error, { - Ok(U32OrBool::Bool(b)) + Ok(U32OrBool::U32(u as u32)) } } @@ -361,16 +361,16 @@ impl<'de> de::Deserialize<'de> for StringOrBool { formatter.write_str("a boolean or a string") } - fn visit_str(self, s: &str) -> Result + fn visit_bool(self, b: bool) -> Result where E: de::Error, { - Ok(StringOrBool::String(s.to_string())) + Ok(StringOrBool::Bool(b)) } - fn visit_bool(self, b: bool) -> Result + fn visit_str(self, s: &str) -> Result where E: de::Error, { - Ok(StringOrBool::Bool(b)) + Ok(StringOrBool::String(s.to_string())) } } @@ -604,9 +604,9 @@ impl TomlManifest { let mut cx = Context { pkgid: Some(&pkgid), deps: &mut deps, - source_id: source_id, + source_id, nested_paths: &mut nested_paths, - config: config, + config, warnings: &mut warnings, features: &features, platform: None, @@ -800,13 +800,13 @@ impl TomlManifest { let mut cx = Context { pkgid: None, deps: &mut deps, - source_id: source_id, + source_id, nested_paths: &mut nested_paths, - config: config, + config, warnings: &mut warnings, platform: None, features: &features, - root: root + root }; (me.replace(&mut cx)?, me.patch(&mut cx)?) }; @@ -1207,7 +1207,7 @@ fn build_profiles(profiles: &Option) -> Profiles { Some(StringOrBool::String(ref n)) => Lto::Named(n.clone()), None => profile.lto, }, - codegen_units: codegen_units, + codegen_units, rustc_args: None, rustdoc_args: None, debuginfo: debug.unwrap_or(profile.debuginfo), diff --git a/src/crates-io/lib.rs b/src/crates-io/lib.rs index 19d3e700c60..637fa430398 100644 --- a/src/crates-io/lib.rs +++ b/src/crates-io/lib.rs @@ -103,9 +103,9 @@ impl Registry { token: Option, handle: Easy) -> Registry { Registry { - host: host, - token: token, - handle: handle, + host, + token, + handle, } } @@ -197,8 +197,8 @@ impl Registry { .unwrap_or_else(Vec::new); Ok(Warnings { - invalid_categories: invalid_categories, - invalid_badges: invalid_badges, + invalid_categories, + invalid_badges, }) } diff --git a/tests/testsuite/cargotest/support/git.rs b/tests/testsuite/cargotest/support/git.rs index 439457c232e..0fe2db676dc 100644 --- a/tests/testsuite/cargotest/support/git.rs +++ b/tests/testsuite/cargotest/support/git.rs @@ -27,7 +27,7 @@ impl RepoBuilder { t!(config.set_str("user.name", "name")); t!(config.set_str("user.email", "email")); } - RepoBuilder { repo: repo, files: Vec::new() } + RepoBuilder { repo, files: Vec::new() } } pub fn file(self, path: &str, contents: &str) -> RepoBuilder { diff --git a/tests/testsuite/cargotest/support/mod.rs b/tests/testsuite/cargotest/support/mod.rs index 099e39d1892..07e5f6f3ceb 100644 --- a/tests/testsuite/cargotest/support/mod.rs +++ b/tests/testsuite/cargotest/support/mod.rs @@ -45,7 +45,7 @@ struct FileBuilder { impl FileBuilder { pub fn new(path: PathBuf, body: &str) -> FileBuilder { - FileBuilder { path: path, body: body.to_string() } + FileBuilder { path, body: body.to_string() } } fn mk(&self) { @@ -71,7 +71,7 @@ struct SymlinkBuilder { impl SymlinkBuilder { pub fn new(dst: PathBuf, src: PathBuf) -> SymlinkBuilder { - SymlinkBuilder { dst: dst, src: src } + SymlinkBuilder { dst, src } } #[cfg(unix)] @@ -699,7 +699,7 @@ fn find_mismatch<'a>(expected: &'a Value, actual: &'a Value) assert!(r.len() > 0); Some((&l[0], &r[0])) } else { - assert!(r.len() == 0); + assert_eq!(r.len(), 0); None } } diff --git a/tests/testsuite/cargotest/support/paths.rs b/tests/testsuite/cargotest/support/paths.rs index 8a74fc0f61d..3358036efef 100644 --- a/tests/testsuite/cargotest/support/paths.rs +++ b/tests/testsuite/cargotest/support/paths.rs @@ -67,7 +67,7 @@ pub trait CargoPathExt { self.move_in_time(|sec, nsec| (sec + 3600, nsec)) } - fn move_in_time(&self, F) + fn move_in_time(&self, travel_amount: F) where F: Fn(u64, u32) -> (u64, u32); } diff --git a/tests/testsuite/directory.rs b/tests/testsuite/directory.rs index 47a6173e4b5..6327b7b2cdf 100644 --- a/tests/testsuite/directory.rs +++ b/tests/testsuite/directory.rs @@ -602,7 +602,7 @@ fn git_lock_file_doesnt_change() { let mut lock2 = String::new(); t!(t!(File::open(p.root().join("Cargo.lock"))).read_to_string(&mut lock2)); - assert!(lock1 == lock2, "lock files changed"); + assert_eq!(lock1, lock2, "lock files changed"); } #[test] diff --git a/tests/testsuite/generate_lockfile.rs b/tests/testsuite/generate_lockfile.rs index 30b2651bcca..efd0c6124ec 100644 --- a/tests/testsuite/generate_lockfile.rs +++ b/tests/testsuite/generate_lockfile.rs @@ -42,7 +42,7 @@ fn adding_and_removing_packages() { assert_that(p.cargo("generate-lockfile"), execs().with_status(0)); let lock2 = p.read_lockfile(); - assert!(lock1 != lock2); + assert_ne!(lock1, lock2); // change the dep File::create(&p.root().join("bar/Cargo.toml")).unwrap().write_all(br#" @@ -54,8 +54,8 @@ fn adding_and_removing_packages() { assert_that(p.cargo("generate-lockfile"), execs().with_status(0)); let lock3 = p.read_lockfile(); - assert!(lock1 != lock3); - assert!(lock2 != lock3); + assert_ne!(lock1, lock3); + assert_ne!(lock2, lock3); // remove the dep println!("lock4"); diff --git a/tests/testsuite/install.rs b/tests/testsuite/install.rs index c3da7daa090..edb1dc62700 100644 --- a/tests/testsuite/install.rs +++ b/tests/testsuite/install.rs @@ -901,7 +901,7 @@ fn use_path_workspace() { let lock = p.read_lockfile(); assert_that(p.cargo("install"), execs().with_status(0)); let lock2 = p.read_lockfile(); - assert!(lock == lock2, "different lockfiles"); + assert_eq!(lock, lock2, "different lockfiles"); } #[test] diff --git a/tests/testsuite/patch.rs b/tests/testsuite/patch.rs index 47ca003206f..8a0d754d934 100644 --- a/tests/testsuite/patch.rs +++ b/tests/testsuite/patch.rs @@ -681,7 +681,7 @@ fn remove_patch() { assert!(lock_file1.contains("bar")); assert_eq!(lock_file2, lock_file3); - assert!(lock_file1 != lock_file2); + assert_ne!(lock_file1, lock_file2); } #[test]