Skip to content

Commit 2f97a3b

Browse files
committed
Add a test and a comment
1 parent 2005ae1 commit 2f97a3b

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

src/cargo/sources/source.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ pub trait Source {
146146
fn describe(&self) -> String;
147147

148148
/// Returns whether a source is being replaced by another here.
149+
///
150+
/// Builtin replacement of `crates.io` doesn't count as replacement here.
149151
fn is_replaced(&self) -> bool {
150152
false
151153
}

tests/testsuite/registry.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3833,3 +3833,43 @@ fn builtin_source_replacement() {
38333833
)
38343834
.run();
38353835
}
3836+
3837+
#[cargo_test]
3838+
fn builtin_source_replacement_no_vendor_error() {
3839+
// errors for builtin source replacement of crates.io
3840+
// should not mention outdated vendor dependencies
3841+
let server = RegistryBuilder::new().build();
3842+
3843+
let p = project()
3844+
.file(
3845+
"Cargo.toml",
3846+
r#"
3847+
[package]
3848+
name = "foo"
3849+
version = "0.0.1"
3850+
edition = "2021"
3851+
3852+
[dependencies]
3853+
dep = "0.2.0"
3854+
"#,
3855+
)
3856+
.file("src/main.rs", "fn main() {}")
3857+
.build();
3858+
3859+
let pkg = Package::new("dep", "0.1.0");
3860+
pkg.publish();
3861+
3862+
p.cargo("check -v")
3863+
.replace_crates_io(&server.index_url())
3864+
.with_status(101)
3865+
.with_stderr(
3866+
"\
3867+
[UPDATING] [..] index
3868+
[ERROR] failed to select a version for the requirement `dep = \"^0.2.0\"`
3869+
candidate versions found which didn't match: 0.1.0
3870+
location searched: crates.io index
3871+
required by package `foo v0.0.1 ([..])`
3872+
",
3873+
)
3874+
.run();
3875+
}

0 commit comments

Comments
 (0)