Skip to content

Commit

Permalink
Fix confusing error messages when using -Zsparse-registry
Browse files Browse the repository at this point in the history
  • Loading branch information
arlosi committed Oct 24, 2022
1 parent 6e9da76 commit f6c03e7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
5 changes: 4 additions & 1 deletion src/cargo/core/source/source_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,10 @@ impl SourceId {
let url = self.inner.url.as_str();
url == CRATES_IO_INDEX
|| url == CRATES_IO_HTTP_INDEX
|| std::env::var("__CARGO_TEST_CRATES_IO_URL_DO_NOT_USE_THIS").as_deref() == Ok(url)
|| std::env::var("__CARGO_TEST_CRATES_IO_URL_DO_NOT_USE_THIS")
.as_deref()
.map(|u| u.trim_start_matches("sparse+"))
== Ok(url)
}

/// Hashes `self`.
Expand Down
14 changes: 9 additions & 5 deletions src/cargo/sources/replaced.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,15 @@ impl<'cfg> Source for ReplacedSource<'cfg> {
}

fn describe(&self) -> String {
format!(
"{} (which is replacing {})",
self.inner.describe(),
self.to_replace
)
if self.replace_with.is_crates_io() {
self.inner.describe()
} else {
format!(
"{} (which is replacing {})",
self.inner.describe(),
self.to_replace
)
}
}

fn is_replaced(&self) -> bool {
Expand Down
12 changes: 6 additions & 6 deletions tests/testsuite/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2319,13 +2319,13 @@ fn wait_for_publish() {
.with_status(0)
.with_stderr(
"\
[UPDATING] `crates-io` index
[UPDATING] crates.io index
[WARNING] manifest has no documentation, [..]
See [..]
[PACKAGING] delay v0.0.1 ([CWD])
[UPLOADING] delay v0.0.1 ([CWD])
[UPDATING] `crates-io` index
[WAITING] on `delay` to propagate to `crates-io` index (which is replacing registry `crates-io`) (ctrl-c to wait asynchronously)
[UPDATING] crates.io index
[WAITING] on `delay` to propagate to crates.io index (ctrl-c to wait asynchronously)
",
)
.run();
Expand Down Expand Up @@ -2416,13 +2416,13 @@ fn wait_for_publish_underscore() {
.with_status(0)
.with_stderr(
"\
[UPDATING] `crates-io` index
[UPDATING] crates.io index
[WARNING] manifest has no documentation, [..]
See [..]
[PACKAGING] delay_with_underscore v0.0.1 ([CWD])
[UPLOADING] delay_with_underscore v0.0.1 ([CWD])
[UPDATING] `crates-io` index
[WAITING] on `delay_with_underscore` to propagate to `crates-io` index (which is replacing registry `crates-io`) (ctrl-c to wait asynchronously)
[UPDATING] crates.io index
[WAITING] on `delay_with_underscore` to propagate to crates.io index (ctrl-c to wait asynchronously)
",
)
.run();
Expand Down

0 comments on commit f6c03e7

Please sign in to comment.