Commit 56619d83 authored by Ryan Hunt's avatar Ryan Hunt
Browse files

Make [root] section of Cargo.lock optional as rust 1.22 seems to no longer emit it

parent eefe8279
......@@ -100,20 +100,22 @@ impl Cargo {
// look for that too.
let replaced_name = dependency_name.replace("_", "-");
if lock.root.name == package.name && lock.root.version == package.version {
if let Some(ref deps) = lock.root.dependencies {
for dep in deps {
let (name, version) = parse_dep_string(dep);
if name == dependency_name || name == &replaced_name {
return Some(PackageRef {
name: name.to_owned(),
version: version.to_owned(),
});
if let &Some(ref root) = &lock.root {
if root.name == package.name && root.version == package.version {
if let Some(ref deps) = root.dependencies {
for dep in deps {
let (name, version) = parse_dep_string(dep);
if name == dependency_name || name == &replaced_name {
return Some(PackageRef {
name: name.to_owned(),
version: version.to_owned(),
});
}
}
}
return None;
}
return None;
}
if let &Some(ref lock_packages) = &lock.package {
......
......@@ -31,7 +31,7 @@ impl From<toml::de::Error> for Error {
#[derive(Clone, Deserialize, Debug)]
pub struct Lock {
pub root: Package,
pub root: Option<Package>,
pub package: Option<Vec<Package>>,
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment