Skip to content

Commit

Permalink
Minor style update.
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed Apr 27, 2018
1 parent 040f984 commit e82e9c1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/cargo/core/package_id_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use core::PackageId;
use util::{ToSemver, ToUrl};
use util::errors::{CargoResult, CargoResultExt};

/// Some or all of the data required to indentify a package:
/// Some or all of the data required to identify a package:
///
/// 1. the package name (a `String`, required)
/// 2. the package version (a `Version`, optional)
Expand Down
43 changes: 24 additions & 19 deletions src/cargo/core/profiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,26 +173,31 @@ impl ProfileMaker {
}

fn validate_packages(&self, shell: &mut Shell, packages: &HashSet<&str>) -> CargoResult<()> {
if let Some(ref toml) = self.toml {
if let Some(ref overrides) = toml.overrides {
for key in overrides.keys().filter(|k| k.as_str() != "*") {
if !packages.contains(key.as_str()) {
let suggestion = packages
.iter()
.map(|p| (lev_distance(key, p), p))
.filter(|&(d, _)| d < 4)
.min_by_key(|p| p.0)
.map(|p| p.1);
match suggestion {
Some(p) => shell.warn(format!(
"package `{}` for profile override not found\n\nDid you mean `{}`?",
key, p
))?,
None => shell
.warn(format!("package `{}` for profile override not found", key))?,
};
let toml = match self.toml {
Some(ref toml) => toml,
None => return Ok(()),
};
let overrides = match toml.overrides {
Some(ref overrides) => overrides,
None => return Ok(()),
};
for key in overrides.keys().filter(|k| k.as_str() != "*") {
if !packages.contains(key.as_str()) {
let suggestion = packages
.iter()
.map(|p| (lev_distance(key, p), p))
.filter(|&(d, _)| d < 4)
.min_by_key(|p| p.0)
.map(|p| p.1);
match suggestion {
Some(p) => shell.warn(format!(
"package `{}` for profile override not found\n\nDid you mean `{}`?",
key, p
))?,
None => {
shell.warn(format!("package `{}` for profile override not found", key))?
}
}
};
}
}
Ok(())
Expand Down

0 comments on commit e82e9c1

Please sign in to comment.