diff --git a/src/cargo/core/compiler/build_config.rs b/src/cargo/core/compiler/build_config.rs index 0ba59ecc947..893d9e08183 100644 --- a/src/cargo/core/compiler/build_config.rs +++ b/src/cargo/core/compiler/build_config.rs @@ -18,7 +18,7 @@ impl ProfileKind { match self { ProfileKind::Dev => "dev", ProfileKind::Release => "release", - ProfileKind::Custom(name) => &name, + ProfileKind::Custom(name) => name, } } } diff --git a/src/cargo/core/compiler/build_context/mod.rs b/src/cargo/core/compiler/build_context/mod.rs index c21938bbb3f..d2e31681607 100644 --- a/src/cargo/core/compiler/build_context/mod.rs +++ b/src/cargo/core/compiler/build_context/mod.rs @@ -111,7 +111,7 @@ impl<'a, 'cfg> BuildContext<'a, 'cfg> { None => return true, }; let name = kind.short_name(self); - platform.matches(&name, self.cfg(kind)) + platform.matches(name, self.cfg(kind)) } /// Gets the user-specified linker for a particular host or target. diff --git a/src/cargo/core/profiles.rs b/src/cargo/core/profiles.rs index 7ea1cd1cf6c..2428285f13b 100644 --- a/src/cargo/core/profiles.rs +++ b/src/cargo/core/profiles.rs @@ -251,7 +251,7 @@ impl Profiles { _ => {} }; - let mut maker = self.process_chain(name, &profile, &mut set, &mut result, profiles)?; + let mut maker = self.process_chain(name, profile, &mut set, &mut result, profiles)?; result.reverse(); maker.inherits = result; @@ -263,7 +263,7 @@ impl Profiles { fn process_chain( &mut self, - name: &String, + name: &str, profile: &TomlProfile, set: &mut HashSet, result: &mut Vec, @@ -273,7 +273,7 @@ impl Profiles { match profile.inherits.as_ref().map(|x| x.as_str()) { Some(name @ "dev") | Some(name @ "release") => { // These are the root profiles - return Ok(self.by_name.get(name).unwrap().clone()); + Ok(self.by_name.get(name).unwrap().clone()) } Some(name) => { let name = name.to_owned(); diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs index a6eba3dbe86..7c43fbdd7c1 100644 --- a/src/cargo/ops/cargo_package.rs +++ b/src/cargo/ops/cargo_package.rs @@ -292,13 +292,11 @@ fn check_repo_state( if let Ok(status) = repo.status_file(relative) { if status == git2::Status::CURRENT { false + } else if relative.to_str().unwrap_or("") == "Cargo.lock" { + // It is OK to include this file even if it is ignored. + status != git2::Status::IGNORED } else { - if relative.to_str().unwrap_or("") == "Cargo.lock" { - // It is OK to include this file even if it is ignored. - status != git2::Status::IGNORED - } else { - true - } + true } } else { submodule_dirty(file) diff --git a/src/cargo/ops/cargo_test.rs b/src/cargo/ops/cargo_test.rs index f49821cdfef..005b1857725 100644 --- a/src/cargo/ops/cargo_test.rs +++ b/src/cargo/ops/cargo_test.rs @@ -170,12 +170,12 @@ fn run_doc_tests( p.arg("--enable-per-target-ignores"); } - runtool.as_ref().map(|(runtool, runtool_args)| { + if let Some((runtool, runtool_args)) = runtool { p.arg("--runtool").arg(runtool); for arg in runtool_args { p.arg("--runtool-arg").arg(arg); } - }); + } for &rust_dep in &[&compilation.deps_output] { let mut arg = OsString::from("dependency="); diff --git a/src/cargo/ops/common_for_install_and_uninstall.rs b/src/cargo/ops/common_for_install_and_uninstall.rs index 3fec1ee436c..9016c9c5268 100644 --- a/src/cargo/ops/common_for_install_and_uninstall.rs +++ b/src/cargo/ops/common_for_install_and_uninstall.rs @@ -527,7 +527,7 @@ impl InstallInfo { self.features == feature_set(&opts.features) && self.all_features == opts.all_features && self.no_default_features == opts.no_default_features - && self.profile == opts.build_config.profile_name().to_string() + && self.profile == opts.build_config.profile_name() && (self.target.is_none() || self.target.as_ref().map(|t| t.as_ref()) == Some(target)) && &self.bins == exes } diff --git a/src/cargo/util/command_prelude.rs b/src/cargo/util/command_prelude.rs index 2d0a9b3fc5e..860ca0d2fda 100644 --- a/src/cargo/util/command_prelude.rs +++ b/src/cargo/util/command_prelude.rs @@ -313,10 +313,8 @@ pub trait ArgMatchesExt { match profile_checking { ProfileChecking::Unchecked => {} ProfileChecking::Checked => { - if specified_profile.is_some() { - if !config.cli_unstable().unstable_options { - failure::bail!("Usage of `--profile` requires `-Z unstable-options`") - } + if specified_profile.is_some() && !config.cli_unstable().unstable_options { + failure::bail!("Usage of `--profile` requires `-Z unstable-options`") } } } diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index d69831752c8..91531d112a3 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -287,7 +287,7 @@ impl TomlProfiles { warnings.push("use `[profile.dev]` to configure debug builds".to_string()); } - profile.validate(&name, features, warnings)?; + profile.validate(name, features, warnings)?; } Ok(()) } @@ -490,7 +490,7 @@ impl TomlProfile { match &self.dir_name { None => {} Some(dir_name) => { - Self::validate_name(&dir_name, "dir-name")?; + Self::validate_name(dir_name, "dir-name")?; } } @@ -498,7 +498,7 @@ impl TomlProfile { match &self.inherits { None => {} Some(inherits) => { - Self::validate_name(&inherits, "inherits")?; + Self::validate_name(inherits, "inherits")?; } } @@ -581,7 +581,7 @@ impl TomlProfile { } if let Some(v) = profile.codegen_units { - self.codegen_units = Some(v.clone()); + self.codegen_units = Some(v); } if let Some(v) = &profile.debug { @@ -589,11 +589,11 @@ impl TomlProfile { } if let Some(v) = profile.debug_assertions { - self.debug_assertions = Some(v.clone()); + self.debug_assertions = Some(v); } if let Some(v) = profile.rpath { - self.rpath = Some(v.clone()); + self.rpath = Some(v); } if let Some(v) = &profile.panic { @@ -601,11 +601,11 @@ impl TomlProfile { } if let Some(v) = profile.overflow_checks { - self.overflow_checks = Some(v.clone()); + self.overflow_checks = Some(v); } if let Some(v) = profile.incremental { - self.incremental = Some(v.clone()); + self.incremental = Some(v); } if let Some(v) = &profile.overrides {