Skip to content

Commit 436f290

Browse files
committed
Auto merge of #6750 - hugwijst:yanked_local_registry_bug_backport, r=ehuss
[backport] Fix resolving yanked crates when using a local registry. This is a backport #6742 to fix #6741.
2 parents 5c6aa46 + 3dc78b5 commit 436f290

File tree

4 files changed

+55
-9
lines changed

4 files changed

+55
-9
lines changed

src/cargo/core/source/source_id.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,12 @@ impl SourceId {
283283
Ok(p) => p,
284284
Err(()) => panic!("path sources cannot be remote"),
285285
};
286-
Ok(Box::new(RegistrySource::local(self, &path, config)))
286+
Ok(Box::new(RegistrySource::local(
287+
self,
288+
&path,
289+
yanked_whitelist,
290+
config,
291+
)))
287292
}
288293
Kind::Directory => {
289294
let path = match self.inner.url.to_file_path() {

src/cargo/sources/registry/mod.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -404,15 +404,20 @@ impl<'cfg> RegistrySource<'cfg> {
404404
)
405405
}
406406

407-
pub fn local(source_id: SourceId, path: &Path, config: &'cfg Config) -> RegistrySource<'cfg> {
407+
pub fn local(
408+
source_id: SourceId,
409+
path: &Path,
410+
yanked_whitelist: &HashSet<PackageId>,
411+
config: &'cfg Config,
412+
) -> RegistrySource<'cfg> {
408413
let name = short_name(source_id);
409414
let ops = local::LocalRegistry::new(path, config, &name);
410415
RegistrySource::new(
411416
source_id,
412417
config,
413418
&name,
414419
Box::new(ops),
415-
&HashSet::new(),
420+
yanked_whitelist,
416421
false,
417422
)
418423
}

tests/testsuite/doc.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -1372,7 +1372,7 @@ fn doc_message_format() {
13721372

13731373
p.cargo("doc --message-format=json")
13741374
.with_status(101)
1375-
.with_json(
1375+
.with_json_contains_unordered(
13761376
r#"
13771377
{
13781378
"message": {
@@ -1402,10 +1402,7 @@ fn short_message_format() {
14021402
p.cargo("doc --message-format=short")
14031403
.with_status(101)
14041404
.with_stderr_contains(
1405-
"\
1406-
src/lib.rs:4:6: error: `[bad_link]` cannot be resolved, ignoring it...
1407-
error: Could not document `foo`.
1408-
",
1405+
"src/lib.rs:4:6: error: `[bad_link]` cannot be resolved, ignoring it...",
14091406
)
14101407
.run();
14111408
}

tests/testsuite/local_registry.rs

+40-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::fs::{self, File};
22
use std::io::prelude::*;
33

44
use crate::support::paths::{self, CargoPathExt};
5-
use crate::support::registry::Package;
5+
use crate::support::registry::{registry_path, Package};
66
use crate::support::{basic_manifest, project};
77

88
fn setup() {
@@ -61,6 +61,45 @@ fn simple() {
6161
p.cargo("test").run();
6262
}
6363

64+
#[test]
65+
fn depend_on_yanked() {
66+
setup();
67+
Package::new("bar", "0.0.1").local(true).publish();
68+
69+
let p = project()
70+
.file(
71+
"Cargo.toml",
72+
r#"
73+
[project]
74+
name = "foo"
75+
version = "0.0.1"
76+
authors = []
77+
78+
[dependencies]
79+
bar = "0.0.1"
80+
"#,
81+
)
82+
.file("src/lib.rs", "")
83+
.build();
84+
85+
// Run cargo to create lock file.
86+
p.cargo("check").run();
87+
88+
registry_path().join("index").join("3").rm_rf();
89+
Package::new("bar", "0.0.1")
90+
.local(true)
91+
.yanked(true)
92+
.publish();
93+
94+
p.cargo("check")
95+
.with_stderr(
96+
"\
97+
[FINISHED] [..]
98+
",
99+
)
100+
.run();
101+
}
102+
64103
#[test]
65104
fn multiple_versions() {
66105
setup();

0 commit comments

Comments
 (0)