From 949145f745c1ffe8b813df99133e97dcb7c3b53b Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Fri, 5 Oct 2018 14:05:24 -0700 Subject: [PATCH] Fix dashes in rename dependencies. --- src/cargo/core/resolver/resolve.rs | 6 +++--- tests/testsuite/rename_deps.rs | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/cargo/core/resolver/resolve.rs b/src/cargo/core/resolver/resolve.rs index 3a5a090d93c..61f3c60b69e 100644 --- a/src/cargo/core/resolver/resolve.rs +++ b/src/cargo/core/resolver/resolve.rs @@ -224,10 +224,10 @@ unable to verify that `{0}` is the same as when the lockfile was generated let crate_name = to_target.crate_name(); let mut names = deps.iter().map(|d| { d.explicit_name_in_toml() - .map(|s| s.as_str()) - .unwrap_or(&crate_name) + .map(|s| s.as_str().replace("-", "_")) + .unwrap_or(crate_name.clone()) }); - let name = names.next().unwrap_or(&crate_name); + let name = names.next().unwrap_or(crate_name.clone()); for n in names { if n == name { continue; diff --git a/tests/testsuite/rename_deps.rs b/tests/testsuite/rename_deps.rs index 7f996f696f1..c444739b0f2 100644 --- a/tests/testsuite/rename_deps.rs +++ b/tests/testsuite/rename_deps.rs @@ -433,3 +433,28 @@ Caused by: ", ).run(); } + +#[test] +fn rename_with_dash() { + let p = project() + .file( + "Cargo.toml", + r#" + cargo-features = ["rename-dependency"] + [package] + name = "qwerty" + version = "0.1.0" + + [dependencies] + foo-bar = { path = 'a', package = 'a' } + "#, + ) + .file("src/lib.rs", "extern crate foo_bar;") + .file("a/Cargo.toml", &basic_manifest("a", "0.1.0")) + .file("a/src/lib.rs", "") + .build(); + + p.cargo("build") + .masquerade_as_nightly_cargo() + .run(); +}