Skip to content

Commit 796257c

Browse files
authored
Merge pull request #161 from leoschwarz/rename-crates
Implement support for now stable rename_dependency feature. Fixes #133.
2 parents c9b710a + 8745a25 commit 796257c

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/cargo_ops/temp_project.rs

+13-4
Original file line numberDiff line numberDiff line change
@@ -371,11 +371,13 @@ impl<'tmp> TempProject<'tmp> {
371371
package_name: &str,
372372
version_to_latest: bool,
373373
) -> CargoResult<()> {
374-
let dep_names: Vec<_> = dependencies.keys().cloned().collect();
375-
for name in dep_names {
376-
let original = dependencies.get(&name).cloned().unwrap();
374+
let dep_keys: Vec<_> = dependencies.keys().cloned().collect();
375+
for dep_key in dep_keys {
376+
let original = dependencies.get(&dep_key).cloned().unwrap();
377+
377378
match original {
378379
Value::String(requirement) => {
380+
let name = dep_key;
379381
if version_to_latest {
380382
dependencies.insert(
381383
name.clone(),
@@ -394,6 +396,13 @@ impl<'tmp> TempProject<'tmp> {
394396
}
395397
}
396398
Value::Table(ref t) => {
399+
let name = match t.get("package") {
400+
Some(&Value::String(ref s)) => s,
401+
// TODO: Probably this should emit an error?
402+
Some(_) => &dep_key,
403+
None => &dep_key,
404+
};
405+
397406
if !(version_to_latest || t.contains_key("features")) {
398407
continue;
399408
}
@@ -463,7 +472,7 @@ impl<'tmp> TempProject<'tmp> {
463472
}
464473
dependencies.insert(name.clone(), Value::Table(replaced));
465474
}
466-
_ => panic!("Dependency spec is neither a string nor a table {}", name),
475+
_ => panic!("Dependency spec is neither a string nor a table {}", dep_key),
467476
}
468477
}
469478
Ok(())

0 commit comments

Comments
 (0)