Skip to content

Commit

Permalink
Auto merge of #6140 - ehuss:fix-dash-rename, r=alexcrichton
Browse files Browse the repository at this point in the history
Fix dashes in rename dependencies.

Fixes #6138
  • Loading branch information
bors committed Oct 5, 2018
2 parents 45460b2 + 949145f commit 6f9ef6e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/cargo/core/resolver/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
25 changes: 25 additions & 0 deletions tests/testsuite/rename_deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

0 comments on commit 6f9ef6e

Please sign in to comment.