mirror of
https://github.com/rust-lang/cargo
synced 2024-08-28 03:39:31 +00:00
refactor(toml): Rely on resolved license-file
This commit is contained in:
parent
b942be5bc1
commit
18550b2512
|
@ -245,6 +245,10 @@ impl TomlPackage {
|
|||
pub fn resolved_license(&self) -> Result<Option<&String>, UnresolvedError> {
|
||||
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.
|
||||
|
|
|
@ -608,6 +608,16 @@ pub fn to_real_manifest(
|
|||
.map(|value| field_inherit_with(value, "license", || inherit()?.license()))
|
||||
.transpose()?
|
||||
.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
|
||||
.resolved_rust_version()
|
||||
|
@ -934,10 +944,9 @@ pub fn to_real_manifest(
|
|||
.expect("previously resolved")
|
||||
.cloned(),
|
||||
license_file: package
|
||||
.license_file
|
||||
.clone()
|
||||
.map(|mw| field_inherit_with(mw, "license", || inherit()?.license_file(package_root)))
|
||||
.transpose()?,
|
||||
.resolved_license_file()
|
||||
.expect("previously resolved")
|
||||
.cloned(),
|
||||
repository: package
|
||||
.repository
|
||||
.clone()
|
||||
|
@ -966,10 +975,6 @@ pub fn to_real_manifest(
|
|||
.authors
|
||||
.as_ref()
|
||||
.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
|
||||
.repository
|
||||
.clone()
|
||||
|
|
Loading…
Reference in a new issue