Skip to content

Commit c9bdd3e

Browse files
committed
Auto merge of #4170 - alexcrichton:beta-next2, r=alexcrichton
[beta] Preserve `package.metadata` when packaging Now that we use Serde this is actually trivial to implement! Closes #4142
2 parents cd8455c + 19394d7 commit c9bdd3e

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/cargo/util/toml.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,7 @@ pub fn to_manifest(contents: &str,
109109
let manifest: TomlManifest = serde_ignored::deserialize(root, |path| {
110110
let mut key = String::new();
111111
stringify(&mut key, &path);
112-
if !key.starts_with("package.metadata") {
113-
unused.insert(key);
114-
}
112+
unused.insert(key);
115113
})?;
116114

117115
let manifest = Rc::new(manifest);
@@ -459,6 +457,7 @@ pub struct TomlProject {
459457
#[serde(rename = "license-file")]
460458
license_file: Option<String>,
461459
repository: Option<String>,
460+
metadata: Option<toml::Value>,
462461
}
463462

464463
#[derive(Deserialize, Serialize)]

tests/package.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,9 @@ fn generated_manifest() {
604604
license = "MIT"
605605
description = "foo"
606606
607+
[project.metadata]
608+
foo = 'bar'
609+
607610
[workspace]
608611
609612
[dependencies]
@@ -652,6 +655,9 @@ authors = []
652655
exclude = ["*.txt"]
653656
description = "foo"
654657
license = "MIT"
658+
659+
[package.metadata]
660+
foo = "bar"
655661
[dependencies.bar]
656662
version = "0.1"
657663
"#));

0 commit comments

Comments
 (0)