diff --git a/src/cargo/sources/replaced.rs b/src/cargo/sources/replaced.rs index 72b25596384..c64257908a6 100644 --- a/src/cargo/sources/replaced.rs +++ b/src/cargo/sources/replaced.rs @@ -152,7 +152,7 @@ impl<'gctx> Source for ReplacedSource<'gctx> { } fn is_replaced(&self) -> bool { - true + !self.is_builtin_replacement() } fn add_to_yanked_whitelist(&mut self, pkgs: &[PackageId]) { diff --git a/src/cargo/sources/source.rs b/src/cargo/sources/source.rs index 461a0008e1d..377ac385e11 100644 --- a/src/cargo/sources/source.rs +++ b/src/cargo/sources/source.rs @@ -146,6 +146,8 @@ pub trait Source { fn describe(&self) -> String; /// Returns whether a source is being replaced by another here. + /// + /// Builtin replacement of `crates.io` doesn't count as replacement here. fn is_replaced(&self) -> bool { false } diff --git a/tests/testsuite/registry.rs b/tests/testsuite/registry.rs index 24c253c5504..63f318877a6 100644 --- a/tests/testsuite/registry.rs +++ b/tests/testsuite/registry.rs @@ -3833,3 +3833,43 @@ fn builtin_source_replacement() { ) .run(); } + +#[cargo_test] +fn builtin_source_replacement_no_vendor_error() { + // errors for builtin source replacement of crates.io + // should not mention outdated vendor dependencies + let server = RegistryBuilder::new().build(); + + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.0.1" + edition = "2021" + + [dependencies] + dep = "0.2.0" + "#, + ) + .file("src/main.rs", "fn main() {}") + .build(); + + let pkg = Package::new("dep", "0.1.0"); + pkg.publish(); + + p.cargo("check -v") + .replace_crates_io(&server.index_url()) + .with_status(101) + .with_stderr( + "\ +[UPDATING] [..] index +[ERROR] failed to select a version for the requirement `dep = \"^0.2.0\"` +candidate versions found which didn't match: 0.1.0 +location searched: crates.io index +required by package `foo v0.0.1 ([..])` +", + ) + .run(); +}