mirror of
https://github.com/rust-lang/cargo
synced 2024-08-27 19:29:21 +00:00
refactor(toml): Rely on resolved categories
This commit is contained in:
parent
258d8447a9
commit
047c1fe9d0
|
@ -237,6 +237,10 @@ impl TomlPackage {
|
||||||
pub fn resolved_keywords(&self) -> Result<Option<&Vec<String>>, UnresolvedError> {
|
pub fn resolved_keywords(&self) -> Result<Option<&Vec<String>>, UnresolvedError> {
|
||||||
self.keywords.as_ref().map(|v| v.resolved()).transpose()
|
self.keywords.as_ref().map(|v| v.resolved()).transpose()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn resolved_categories(&self) -> Result<Option<&Vec<String>>, UnresolvedError> {
|
||||||
|
self.categories.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.
|
||||||
|
|
|
@ -596,6 +596,12 @@ pub fn to_real_manifest(
|
||||||
.map(|value| field_inherit_with(value, "keywords", || inherit()?.keywords()))
|
.map(|value| field_inherit_with(value, "keywords", || inherit()?.keywords()))
|
||||||
.transpose()?
|
.transpose()?
|
||||||
.map(manifest::InheritableField::Value);
|
.map(manifest::InheritableField::Value);
|
||||||
|
package.categories = package
|
||||||
|
.categories
|
||||||
|
.clone()
|
||||||
|
.map(|value| field_inherit_with(value, "categories", || inherit()?.categories()))
|
||||||
|
.transpose()?
|
||||||
|
.map(manifest::InheritableField::Value);
|
||||||
|
|
||||||
let rust_version = package
|
let rust_version = package
|
||||||
.resolved_rust_version()
|
.resolved_rust_version()
|
||||||
|
@ -938,10 +944,9 @@ pub fn to_real_manifest(
|
||||||
.cloned()
|
.cloned()
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
categories: package
|
categories: package
|
||||||
.categories
|
.resolved_categories()
|
||||||
.clone()
|
.expect("previously resolved")
|
||||||
.map(|mw| field_inherit_with(mw, "categories", || inherit()?.categories()))
|
.cloned()
|
||||||
.transpose()?
|
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
badges: original_toml
|
badges: original_toml
|
||||||
.badges
|
.badges
|
||||||
|
@ -968,10 +973,6 @@ pub fn to_real_manifest(
|
||||||
.repository
|
.repository
|
||||||
.clone()
|
.clone()
|
||||||
.map(|repository| manifest::InheritableField::Value(repository));
|
.map(|repository| manifest::InheritableField::Value(repository));
|
||||||
package.categories = package
|
|
||||||
.categories
|
|
||||||
.as_ref()
|
|
||||||
.map(|_| manifest::InheritableField::Value(metadata.categories.clone()));
|
|
||||||
package.exclude = package
|
package.exclude = package
|
||||||
.exclude
|
.exclude
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
|
Loading…
Reference in a new issue