Some(Kind::Development)));
}
}
+
+ if let Some(ref map) = self.replace {
+ for (spec, replacement) in map {
+ let spec = try!(PackageIdSpec::parse(spec));
+
+ let version_specified = match *replacement {
+ TomlDependency::Detailed(ref d) => d.version.is_some(),
+ TomlDependency::Simple(..) => true,
+ };
+ if version_specified {
+ bail!("replacements cannot specify a version \
+ requirement, but found one for `{}`", spec);
+ }
+
+ let dep = try!(replacement.to_dependency(spec.name(),
+ &mut cx,
+ None));
+ let dep = {
+ let version = try!(spec.version().chain_error(|| {
+ human(format!("replacements must specify a version \
+ to replace, but `{}` does not",
+ spec))
+ }));
+ let req = VersionReq::exact(version);
+ dep.clone_inner().set_version_req(req)
+ .into_dependency()
+ };
+ replace.push((spec, dep));
+ }
+ }
}
+ {
+ let mut names_sources = HashMap::new();
+ for dep in deps.iter() {
+ let name = dep.name();
+ let prev = names_sources.insert(name, dep.source_id());
+ if prev.is_some() && prev != Some(dep.source_id()) {
+ bail!("found duplicate dependency name {}, but all \
+ dependencies must have a unique name", name);
+ }
+ }
+ }
+
let exclude = project.exclude.clone().unwrap_or(Vec::new());
let include = project.include.clone().unwrap_or(Vec::new());