refactor(toml): Rely on resolved license-file

This commit is contained in:
Ed Page 2024-03-19 14:11:00 -05:00
parent b942be5bc1
commit 18550b2512
2 changed files with 17 additions and 8 deletions

View file

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

View file

@ -608,6 +608,16 @@ pub fn to_real_manifest(
.map(|value| field_inherit_with(value, "license", || inherit()?.license())) .map(|value| field_inherit_with(value, "license", || inherit()?.license()))
.transpose()? .transpose()?
.map(manifest::InheritableField::Value); .map(manifest::InheritableField::Value);
package.license_file = package
.license_file
.clone()
.map(|value| {
field_inherit_with(value, "license-file", || {
inherit()?.license_file(package_root)
})
})
.transpose()?
.map(manifest::InheritableField::Value);
let rust_version = package let rust_version = package
.resolved_rust_version() .resolved_rust_version()
@ -934,10 +944,9 @@ pub fn to_real_manifest(
.expect("previously resolved") .expect("previously resolved")
.cloned(), .cloned(),
license_file: package license_file: package
.license_file .resolved_license_file()
.clone() .expect("previously resolved")
.map(|mw| field_inherit_with(mw, "license", || inherit()?.license_file(package_root))) .cloned(),
.transpose()?,
repository: package repository: package
.repository .repository
.clone() .clone()
@ -966,10 +975,6 @@ pub fn to_real_manifest(
.authors .authors
.as_ref() .as_ref()
.map(|_| manifest::InheritableField::Value(metadata.authors.clone())); .map(|_| manifest::InheritableField::Value(metadata.authors.clone()));
package.license_file = metadata
.license_file
.clone()
.map(|license_file| manifest::InheritableField::Value(license_file));
package.repository = metadata package.repository = metadata
.repository .repository
.clone() .clone()