From 00ba5780e42eeb41f0ba1bae1538f31ef2a33b23 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 19 Mar 2024 14:32:41 -0500 Subject: [PATCH] refactor(toml): Rely on resolved authors --- crates/cargo-util-schemas/src/manifest/mod.rs | 4 ++++ src/cargo/util/toml/mod.rs | 17 +++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/crates/cargo-util-schemas/src/manifest/mod.rs b/crates/cargo-util-schemas/src/manifest/mod.rs index 92c3344c7..f8844df2e 100644 --- a/crates/cargo-util-schemas/src/manifest/mod.rs +++ b/crates/cargo-util-schemas/src/manifest/mod.rs @@ -207,6 +207,10 @@ impl TomlPackage { self.version.as_ref().map(|v| v.resolved()).transpose() } + pub fn resolved_authors(&self) -> Result>, UnresolvedError> { + self.authors.as_ref().map(|v| v.resolved()).transpose() + } + pub fn resolved_description(&self) -> Result, UnresolvedError> { self.description.as_ref().map(|v| v.resolved()).transpose() } diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index 8272f6b7d..eb6973576 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -562,6 +562,12 @@ pub fn to_real_manifest( .map(|value| field_inherit_with(value, "version", || inherit()?.version())) .transpose()? .map(manifest::InheritableField::Value); + package.authors = package + .authors + .clone() + .map(|value| field_inherit_with(value, "authors", || inherit()?.authors())) + .transpose()? + .map(manifest::InheritableField::Value); package.description = package .description .clone() @@ -940,10 +946,9 @@ pub fn to_real_manifest( .expect("previously resolved") .cloned(), authors: package - .authors - .clone() - .map(|mw| field_inherit_with(mw, "authors", || inherit()?.authors())) - .transpose()? + .resolved_authors() + .expect("previously resolved") + .cloned() .unwrap_or_default(), license: package .resolved_license() @@ -976,10 +981,6 @@ pub fn to_real_manifest( links: package.links.clone(), rust_version: rust_version.clone(), }; - package.authors = package - .authors - .as_ref() - .map(|_| manifest::InheritableField::Value(metadata.authors.clone())); package.exclude = package .exclude .as_ref()