Skip to content

Commit 4029326

Browse files
committed
Fix confusing error messages when using -Zsparse-registry
1 parent 6e9da76 commit 4029326

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

src/cargo/core/source/source_id.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,10 @@ impl SourceId {
428428
let url = self.inner.url.as_str();
429429
url == CRATES_IO_INDEX
430430
|| url == CRATES_IO_HTTP_INDEX
431-
|| std::env::var("__CARGO_TEST_CRATES_IO_URL_DO_NOT_USE_THIS").as_deref() == Ok(url)
431+
|| std::env::var("__CARGO_TEST_CRATES_IO_URL_DO_NOT_USE_THIS")
432+
.as_deref()
433+
.map(|u| u.trim_start_matches("sparse+"))
434+
== Ok(url)
432435
}
433436

434437
/// Hashes `self`.

src/cargo/sources/replaced.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,17 @@ impl<'cfg> Source for ReplacedSource<'cfg> {
100100
}
101101

102102
fn describe(&self) -> String {
103-
format!(
104-
"{} (which is replacing {})",
105-
self.inner.describe(),
106-
self.to_replace
107-
)
103+
if self.replace_with.is_crates_io() && self.to_replace.is_crates_io() {
104+
// Built-in source replacement of crates.io for sparse registry or tests
105+
// doesn't need duplicate description (crates.io replacing crates.io).
106+
self.inner.describe()
107+
} else {
108+
format!(
109+
"{} (which is replacing {})",
110+
self.inner.describe(),
111+
self.to_replace
112+
)
113+
}
108114
}
109115

110116
fn is_replaced(&self) -> bool {

tests/testsuite/publish.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2319,13 +2319,13 @@ fn wait_for_publish() {
23192319
.with_status(0)
23202320
.with_stderr(
23212321
"\
2322-
[UPDATING] `crates-io` index
2322+
[UPDATING] crates.io index
23232323
[WARNING] manifest has no documentation, [..]
23242324
See [..]
23252325
[PACKAGING] delay v0.0.1 ([CWD])
23262326
[UPLOADING] delay v0.0.1 ([CWD])
2327-
[UPDATING] `crates-io` index
2328-
[WAITING] on `delay` to propagate to `crates-io` index (which is replacing registry `crates-io`) (ctrl-c to wait asynchronously)
2327+
[UPDATING] crates.io index
2328+
[WAITING] on `delay` to propagate to crates.io index (ctrl-c to wait asynchronously)
23292329
",
23302330
)
23312331
.run();
@@ -2416,13 +2416,13 @@ fn wait_for_publish_underscore() {
24162416
.with_status(0)
24172417
.with_stderr(
24182418
"\
2419-
[UPDATING] `crates-io` index
2419+
[UPDATING] crates.io index
24202420
[WARNING] manifest has no documentation, [..]
24212421
See [..]
24222422
[PACKAGING] delay_with_underscore v0.0.1 ([CWD])
24232423
[UPLOADING] delay_with_underscore v0.0.1 ([CWD])
2424-
[UPDATING] `crates-io` index
2425-
[WAITING] on `delay_with_underscore` to propagate to `crates-io` index (which is replacing registry `crates-io`) (ctrl-c to wait asynchronously)
2424+
[UPDATING] crates.io index
2425+
[WAITING] on `delay_with_underscore` to propagate to crates.io index (ctrl-c to wait asynchronously)
24262426
",
24272427
)
24282428
.run();

0 commit comments

Comments
 (0)