Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix confusing error messages when using -Zsparse-registry #11283

Merged
merged 1 commit into from
Oct 26, 2022
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
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
16 changes: 11 additions & 5 deletions src/cargo/sources/replaced.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,17 @@ 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.to_replace.is_crates_io() {
// Built-in source replacement of crates.io for sparse registry or tests
// doesn't need duplicate description (crates.io replacing 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