diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index a9881497d8d..f6d6c5ea5e1 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -1530,25 +1530,23 @@ fn unique_build_targets( } #[derive(Debug, Deserialize, Serialize, Clone)] +#[serde(rename_all = "kebab-case")] pub struct TomlWorkspace { members: Option>, - #[serde(rename = "default-members")] - default_members: Option>, exclude: Option>, + default_members: Option>, resolver: Option, + metadata: Option, // Properties that can be inherited by members. package: Option, dependencies: Option>, lints: Option, - - // 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, } /// A group of fields that are inheritable by members of the workspace #[derive(Clone, Debug, Default, Deserialize, Serialize)] +#[serde(rename_all = "kebab-case")] pub struct InheritableFields { // We use skip here since it will never be present when deserializing // and we don't want it present when serializing @@ -1566,7 +1564,6 @@ pub struct InheritableFields { keywords: Option>, categories: Option>, license: Option, - #[serde(rename = "license-file")] license_file: Option, repository: Option, publish: Option, @@ -1574,7 +1571,6 @@ pub struct InheritableFields { badges: Option>>, exclude: Option>, include: Option>, - #[serde(rename = "rust-version")] rust_version: Option, // We use skip here since it will never be present when deserializing // and we don't want it present when serializing @@ -1710,13 +1706,11 @@ pub struct TomlPackage { repository: Option, resolver: Option, - // Provide a helpful error message for a common user error. + metadata: Option, + + /// Provide a helpful error message for a common user error. #[serde(rename = "cargo-features", skip_serializing)] _invalid_cargo_features: Option, - - // 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, } impl TomlPackage { @@ -2034,6 +2028,7 @@ impl<'de> de::Deserialize<'de> for MaybeWorkspaceBtreeMap { } #[derive(Deserialize, Serialize, Copy, Clone, Debug)] +#[serde(rename_all = "kebab-case")] pub struct TomlWorkspaceField { #[serde(deserialize_with = "bool_no_false")] workspace: bool, @@ -2064,7 +2059,7 @@ impl MaybeWorkspaceDependency { fn unused_keys(&self) -> Vec { match self { MaybeWorkspaceDependency::Defined(d) => d.unused_keys(), - MaybeWorkspaceDependency::Workspace(w) => w.other.keys().cloned().collect(), + MaybeWorkspaceDependency::Workspace(w) => w.unused_keys.keys().cloned().collect(), } } } @@ -2101,10 +2096,11 @@ pub struct TomlWorkspaceDependency { default_features2: Option, optional: Option, public: Option, + /// This is here to provide a way to see the "unused manifest keys" when deserializing #[serde(skip_serializing)] #[serde(flatten)] - other: BTreeMap, + unused_keys: BTreeMap, } impl TomlWorkspaceDependency { @@ -2212,7 +2208,7 @@ impl TomlDependency { fn unused_keys(&self) -> Vec { match self { TomlDependency::Simple(_) => vec![], - TomlDependency::Detailed(detailed) => detailed.other.keys().cloned().collect(), + TomlDependency::Detailed(detailed) => detailed.unused_keys.keys().cloned().collect(), } } } @@ -2326,10 +2322,11 @@ pub struct DetailedTomlDependency { lib: Option, /// A platform name, like `x86_64-apple-darwin` target: Option, + /// This is here to provide a way to see the "unused manifest keys" when deserializing #[serde(skip_serializing)] #[serde(flatten)] - other: BTreeMap, + unused_keys: BTreeMap, } impl DetailedTomlDependency { @@ -2635,7 +2632,7 @@ impl Default for DetailedTomlDependency

{ artifact: Default::default(), lib: Default::default(), target: Default::default(), - other: Default::default(), + unused_keys: Default::default(), } } } @@ -3383,13 +3380,12 @@ impl TomlTarget { /// Corresponds to a `target` entry, but `TomlTarget` is already used. #[derive(Serialize, Deserialize, Debug, Clone)] +#[serde(rename_all = "kebab-case")] struct TomlPlatform { dependencies: Option>, - #[serde(rename = "build-dependencies")] build_dependencies: Option>, #[serde(rename = "build_dependencies")] build_dependencies2: Option>, - #[serde(rename = "dev-dependencies")] dev_dependencies: Option>, #[serde(rename = "dev_dependencies")] dev_dependencies2: Option>, @@ -3397,6 +3393,7 @@ struct TomlPlatform { #[derive(Deserialize, Serialize, Debug, Clone)] #[serde(expecting = "a lints table")] +#[serde(rename_all = "kebab-case")] pub struct MaybeWorkspaceLints { #[serde(skip_serializing_if = "is_false")] #[serde(deserialize_with = "bool_no_false", default)]