Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1205,7 +1205,13 @@ impl TomlManifest {
for (url, deps) in self.patch.iter().flat_map(|x| x) {
let url = match &url[..] {
CRATES_IO_REGISTRY => CRATES_IO_INDEX.parse().unwrap(),
_ => url.to_url()?,
_ => cx
.config
.get_registry_index(url)
.or_else(|_| url.to_url())
.chain_err(|| {
format!("[patch] entry `{}` should be a URL or registry name", url)
})?,
};
patch.insert(
url,
Expand Down
44 changes: 44 additions & 0 deletions tests/testsuite/alt_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,3 +514,47 @@ fn passwords_in_url_forbidden() {
.with_stderr_contains("error: Registry URLs may not contain passwords")
.run();
}

#[test]
fn patch_alt_reg() {
Package::new("bar", "0.1.0").publish();
let p = project()
.file(
"Cargo.toml",
r#"
cargo-features = ["alternative-registries"]

[package]
name = "foo"
version = "0.0.1"

[dependencies]
bar = { version = "0.1.0", registry = "alternative" }

[patch.alternative]
bar = { path = "bar" }
"#,
)
.file(
"src/lib.rs",
"
extern crate bar;
pub fn f() { bar::bar(); }
",
)
.file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
.file("bar/src/lib.rs", "pub fn bar() {}")
.build();

p.cargo("build")
.masquerade_as_nightly_cargo()
.with_stderr(
"\
[UPDATING] `[ROOT][..]` index
[COMPILING] bar v0.1.0 ([CWD]/bar)
[COMPILING] foo v0.0.1 ([CWD])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
",
)
.run();
}
3 changes: 3 additions & 0 deletions tests/testsuite/patch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,9 @@ fn non_crates_io() {
"\
error: failed to parse manifest at `[..]`

Caused by:
[patch] entry `some-other-source` should be a URL or registry name

Caused by:
invalid url `some-other-source`: relative URL without a base
",
Expand Down