Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement support for now stable rename_dependency feature. Fixes #133. #161

Merged
merged 1 commit into from
Feb 2, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/cargo_ops/temp_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,11 +371,13 @@ impl<'tmp> TempProject<'tmp> {
package_name: &str,
version_to_latest: bool,
) -> CargoResult<()> {
let dep_names: Vec<_> = dependencies.keys().cloned().collect();
for name in dep_names {
let original = dependencies.get(&name).cloned().unwrap();
let dep_keys: Vec<_> = dependencies.keys().cloned().collect();
for dep_key in dep_keys {
let original = dependencies.get(&dep_key).cloned().unwrap();

match original {
Value::String(requirement) => {
let name = dep_key;
if version_to_latest {
dependencies.insert(
name.clone(),
Expand All @@ -394,6 +396,13 @@ impl<'tmp> TempProject<'tmp> {
}
}
Value::Table(ref t) => {
let name = match t.get("package") {
Some(&Value::String(ref s)) => s,
// TODO: Probably this should emit an error?
Some(_) => &dep_key,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I understand "package" for a dependency if present can only be a string indicating the name of the real crates.io package. Right now a "package" value which is not a string is silently ignored, but maybe I should turn that into an error too?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cargo rejects non-strings here, so it'd be OK to reject them too.

None => &dep_key,
};

if !(version_to_latest || t.contains_key("features")) {
continue;
}
Expand Down Expand Up @@ -463,7 +472,7 @@ impl<'tmp> TempProject<'tmp> {
}
dependencies.insert(name.clone(), Value::Table(replaced));
}
_ => panic!("Dependency spec is neither a string nor a table {}", name),
_ => panic!("Dependency spec is neither a string nor a table {}", dep_key),
}
}
Ok(())
Expand Down