mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
Fix publication of packages with metadata and resolver
This commit fixes an issue where packages which specify `resolver = '2'` cannot be packaged if they also have a `package.metadata` table. The issue is that the `toml` serialization implementation serializes fields in order which requires that tables be emitted last.
This commit is contained in:
parent
56b3497205
commit
6bc74556f9
@ -815,8 +815,11 @@ pub struct TomlProject {
|
|||||||
license: Option<String>,
|
license: Option<String>,
|
||||||
license_file: Option<String>,
|
license_file: Option<String>,
|
||||||
repository: Option<String>,
|
repository: Option<String>,
|
||||||
metadata: Option<toml::Value>,
|
|
||||||
resolver: Option<String>,
|
resolver: Option<String>,
|
||||||
|
|
||||||
|
// Note that this field must come last due to the way toml serialization
|
||||||
|
// works which requires tables to be emitted after all values.
|
||||||
|
metadata: Option<toml::Value>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
@ -825,8 +828,11 @@ pub struct TomlWorkspace {
|
|||||||
#[serde(rename = "default-members")]
|
#[serde(rename = "default-members")]
|
||||||
default_members: Option<Vec<String>>,
|
default_members: Option<Vec<String>>,
|
||||||
exclude: Option<Vec<String>>,
|
exclude: Option<Vec<String>>,
|
||||||
metadata: Option<toml::Value>,
|
|
||||||
resolver: Option<String>,
|
resolver: Option<String>,
|
||||||
|
|
||||||
|
// Note that this field must come last due to the way toml serialization
|
||||||
|
// works which requires tables to be emitted after all values.
|
||||||
|
metadata: Option<toml::Value>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TomlProject {
|
impl TomlProject {
|
||||||
|
@ -1954,3 +1954,25 @@ fn reproducible_output() {
|
|||||||
assert_eq!(header.groupname().unwrap().unwrap(), "");
|
assert_eq!(header.groupname().unwrap().unwrap(), "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cargo_test]
|
||||||
|
fn package_with_resolver_and_metadata() {
|
||||||
|
let p = project()
|
||||||
|
.file(
|
||||||
|
"Cargo.toml",
|
||||||
|
r#"
|
||||||
|
[package]
|
||||||
|
name = "foo"
|
||||||
|
version = "0.0.1"
|
||||||
|
authors = []
|
||||||
|
resolver = '2'
|
||||||
|
|
||||||
|
[package.metadata.docs.rs]
|
||||||
|
all-features = true
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.file("src/lib.rs", "")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
p.cargo("package").run();
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user