Skip to content

Commit 69b5bbc

Browse files
committed
Auto merge of #9304 - alexcrichton:backport, r=Eh2406
[beta] Fix publication of packages with metadata and resolver This is as backport of #9300
2 parents 90691f2 + 129f4da commit 69b5bbc

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

src/cargo/util/toml/mod.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -889,8 +889,11 @@ pub struct TomlProject {
889889
license: Option<String>,
890890
license_file: Option<String>,
891891
repository: Option<String>,
892-
metadata: Option<toml::Value>,
893892
resolver: Option<String>,
893+
894+
// Note that this field must come last due to the way toml serialization
895+
// works which requires tables to be emitted after all values.
896+
metadata: Option<toml::Value>,
894897
}
895898

896899
#[derive(Debug, Deserialize, Serialize)]
@@ -899,8 +902,11 @@ pub struct TomlWorkspace {
899902
#[serde(rename = "default-members")]
900903
default_members: Option<Vec<String>>,
901904
exclude: Option<Vec<String>>,
902-
metadata: Option<toml::Value>,
903905
resolver: Option<String>,
906+
907+
// Note that this field must come last due to the way toml serialization
908+
// works which requires tables to be emitted after all values.
909+
metadata: Option<toml::Value>,
904910
}
905911

906912
impl TomlProject {

tests/testsuite/package.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,3 +1954,25 @@ fn reproducible_output() {
19541954
assert_eq!(header.groupname().unwrap().unwrap(), "");
19551955
}
19561956
}
1957+
1958+
#[cargo_test]
1959+
fn package_with_resolver_and_metadata() {
1960+
let p = project()
1961+
.file(
1962+
"Cargo.toml",
1963+
r#"
1964+
[package]
1965+
name = "foo"
1966+
version = "0.0.1"
1967+
authors = []
1968+
resolver = '2'
1969+
1970+
[package.metadata.docs.rs]
1971+
all-features = true
1972+
"#,
1973+
)
1974+
.file("src/lib.rs", "")
1975+
.build();
1976+
1977+
p.cargo("package").run();
1978+
}

0 commit comments

Comments
 (0)