refactor(toml): Rely on resolved license

This commit is contained in:
Ed Page 2024-03-19 14:07:40 -05:00
parent 047c1fe9d0
commit b942be5bc1
2 changed files with 13 additions and 8 deletions

View file

@ -241,6 +241,10 @@ impl TomlPackage {
pub fn resolved_categories(&self) -> Result<Option<&Vec<String>>, UnresolvedError> {
self.categories.as_ref().map(|v| v.resolved()).transpose()
}
pub fn resolved_license(&self) -> Result<Option<&String>, UnresolvedError> {
self.license.as_ref().map(|v| v.resolved()).transpose()
}
}
/// An enum that allows for inheriting keys from a workspace in a Cargo.toml.

View file

@ -602,6 +602,12 @@ pub fn to_real_manifest(
.map(|value| field_inherit_with(value, "categories", || inherit()?.categories()))
.transpose()?
.map(manifest::InheritableField::Value);
package.license = package
.license
.clone()
.map(|value| field_inherit_with(value, "license", || inherit()?.license()))
.transpose()?
.map(manifest::InheritableField::Value);
let rust_version = package
.resolved_rust_version()
@ -924,10 +930,9 @@ pub fn to_real_manifest(
.transpose()?
.unwrap_or_default(),
license: package
.license
.clone()
.map(|mw| field_inherit_with(mw, "license", || inherit()?.license()))
.transpose()?,
.resolved_license()
.expect("previously resolved")
.cloned(),
license_file: package
.license_file
.clone()
@ -961,10 +966,6 @@ pub fn to_real_manifest(
.authors
.as_ref()
.map(|_| manifest::InheritableField::Value(metadata.authors.clone()));
package.license = metadata
.license
.clone()
.map(|license| manifest::InheritableField::Value(license));
package.license_file = metadata
.license_file
.clone()