Skip to content

Commit a268b18

Browse files
committed
fix(package): Register workspace member renames in overlay
This was reported at rust-lang#10948 (comment) I suspect there is a second bug here because my debugging only showed us doing this for `val-json` and not `concepts` and only when building `utils`. For the exact mapping between the publish payload and the index, see https://doc.rust-lang.org/cargo/reference/registry-index.html#json-schema, particularly the note about differences.
1 parent 4213e92 commit a268b18

File tree

2 files changed

+29
-26
lines changed

2 files changed

+29
-26
lines changed

src/cargo/ops/cargo_package/mod.rs

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,22 +1032,33 @@ impl<'a> TmpRegistry<'a> {
10321032
let deps: Vec<_> = new_crate
10331033
.deps
10341034
.into_iter()
1035-
.map(|dep| RegistryDependency {
1036-
name: dep.name.into(),
1037-
req: dep.version_req.into(),
1038-
features: dep.features.into_iter().map(|x| x.into()).collect(),
1039-
optional: dep.optional,
1040-
default_features: dep.default_features,
1041-
target: dep.target.map(|x| x.into()),
1042-
kind: Some(dep.kind.into()),
1043-
registry: dep.registry.map(|x| x.into()),
1044-
package: None,
1045-
public: None,
1046-
artifact: dep
1047-
.artifact
1048-
.map(|xs| xs.into_iter().map(|x| x.into()).collect()),
1049-
bindep_target: dep.bindep_target.map(|x| x.into()),
1050-
lib: dep.lib,
1035+
.map(|dep| {
1036+
let name = dep
1037+
.explicit_name_in_toml
1038+
.clone()
1039+
.unwrap_or_else(|| dep.name.clone())
1040+
.into();
1041+
let package = dep
1042+
.explicit_name_in_toml
1043+
.as_ref()
1044+
.map(|_| dep.name.clone().into());
1045+
RegistryDependency {
1046+
name: name,
1047+
req: dep.version_req.into(),
1048+
features: dep.features.into_iter().map(|x| x.into()).collect(),
1049+
optional: dep.optional,
1050+
default_features: dep.default_features,
1051+
target: dep.target.map(|x| x.into()),
1052+
kind: Some(dep.kind.into()),
1053+
registry: dep.registry.map(|x| x.into()),
1054+
package: package,
1055+
public: None,
1056+
artifact: dep
1057+
.artifact
1058+
.map(|xs| xs.into_iter().map(|x| x.into()).collect()),
1059+
bindep_target: dep.bindep_target.map(|x| x.into()),
1060+
lib: dep.lib,
1061+
}
10511062
})
10521063
.collect();
10531064

tests/testsuite/package.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6566,7 +6566,6 @@ fn workspace_with_renamed_member() {
65666566
p.cargo("package -Zpackage-workspace")
65676567
.masquerade_as_nightly_cargo(&["package-workspace"])
65686568
.replace_crates_io(reg.index_url())
6569-
.with_status(101)
65706569
.with_stderr_data(
65716570
str![[r#"
65726571
[UPDATING] crates.io index
@@ -6588,15 +6587,8 @@ fn workspace_with_renamed_member() {
65886587
[UNPACKING] obeli-sk-concepts v0.16.2 (registry `[ROOT]/foo/target/package/tmp-registry`)
65896588
[COMPILING] obeli-sk-val-json v0.16.2
65906589
[COMPILING] obeli-sk-concepts v0.16.2
6591-
error[E0433]: failed to resolve: use of undeclared crate or module `val_json`
6592-
--> [ROOT]/home/.cargo/registry/src/-[HASH]/obeli-sk-concepts-0.16.2/src/lib.rs:1:16
6593-
|
6594-
1 | pub fn foo() { val_json::foo() }
6595-
| ^^^^^^^^ use of undeclared crate or module `val_json`
6596-
6597-
For more information about this error, try `rustc --explain E0433`.
6598-
[ERROR] could not compile `obeli-sk-concepts` (lib) due to 1 previous error
6599-
[ERROR] failed to verify package tarball
6590+
[COMPILING] obeli-sk-utils v0.16.2 ([ROOT]/foo/target/package/obeli-sk-utils-0.16.2)
6591+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
66006592
66016593
"#]]
66026594
.unordered(),

0 commit comments

Comments
 (0)