Skip to content

Commit 6f9ef6e

Browse files
committed
Auto merge of #6140 - ehuss:fix-dash-rename, r=alexcrichton
Fix dashes in rename dependencies. Fixes #6138
2 parents 45460b2 + 949145f commit 6f9ef6e

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

src/cargo/core/resolver/resolve.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,10 @@ unable to verify that `{0}` is the same as when the lockfile was generated
224224
let crate_name = to_target.crate_name();
225225
let mut names = deps.iter().map(|d| {
226226
d.explicit_name_in_toml()
227-
.map(|s| s.as_str())
228-
.unwrap_or(&crate_name)
227+
.map(|s| s.as_str().replace("-", "_"))
228+
.unwrap_or(crate_name.clone())
229229
});
230-
let name = names.next().unwrap_or(&crate_name);
230+
let name = names.next().unwrap_or(crate_name.clone());
231231
for n in names {
232232
if n == name {
233233
continue;

tests/testsuite/rename_deps.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,3 +433,28 @@ Caused by:
433433
",
434434
).run();
435435
}
436+
437+
#[test]
438+
fn rename_with_dash() {
439+
let p = project()
440+
.file(
441+
"Cargo.toml",
442+
r#"
443+
cargo-features = ["rename-dependency"]
444+
[package]
445+
name = "qwerty"
446+
version = "0.1.0"
447+
448+
[dependencies]
449+
foo-bar = { path = 'a', package = 'a' }
450+
"#,
451+
)
452+
.file("src/lib.rs", "extern crate foo_bar;")
453+
.file("a/Cargo.toml", &basic_manifest("a", "0.1.0"))
454+
.file("a/src/lib.rs", "")
455+
.build();
456+
457+
p.cargo("build")
458+
.masquerade_as_nightly_cargo()
459+
.run();
460+
}

0 commit comments

Comments
 (0)