refactor(toml): Rely on resolved include/exclude

This commit is contained in:
Ed Page 2024-03-19 14:56:07 -05:00
parent 00ba5780e4
commit 20302b34b7
2 changed files with 30 additions and 21 deletions

View file

@ -211,6 +211,14 @@ impl TomlPackage {
self.authors.as_ref().map(|v| v.resolved()).transpose()
}
pub fn resolved_exclude(&self) -> Result<Option<&Vec<String>>, UnresolvedError> {
self.exclude.as_ref().map(|v| v.resolved()).transpose()
}
pub fn resolved_include(&self) -> Result<Option<&Vec<String>>, UnresolvedError> {
self.include.as_ref().map(|v| v.resolved()).transpose()
}
pub fn resolved_description(&self) -> Result<Option<&String>, UnresolvedError> {
self.description.as_ref().map(|v| v.resolved()).transpose()
}

View file

@ -568,6 +568,18 @@ pub fn to_real_manifest(
.map(|value| field_inherit_with(value, "authors", || inherit()?.authors()))
.transpose()?
.map(manifest::InheritableField::Value);
package.exclude = package
.exclude
.clone()
.map(|value| field_inherit_with(value, "exclude", || inherit()?.exclude()))
.transpose()?
.map(manifest::InheritableField::Value);
package.include = package
.include
.clone()
.map(|value| field_inherit_with(value, "include", || inherit()?.include()))
.transpose()?
.map(manifest::InheritableField::Value);
package.description = package
.description
.clone()
@ -915,19 +927,6 @@ pub fn to_real_manifest(
}
}
let exclude = package
.exclude
.clone()
.map(|mw| field_inherit_with(mw, "exclude", || inherit()?.exclude()))
.transpose()?
.unwrap_or_default();
let include = package
.include
.clone()
.map(|mw| field_inherit_with(mw, "include", || inherit()?.include()))
.transpose()?
.unwrap_or_default();
let metadata = ManifestMetadata {
description: package
.resolved_description()
@ -981,14 +980,6 @@ pub fn to_real_manifest(
links: package.links.clone(),
rust_version: rust_version.clone(),
};
package.exclude = package
.exclude
.as_ref()
.map(|_| manifest::InheritableField::Value(exclude.clone()));
package.include = package
.include
.as_ref()
.map(|_| manifest::InheritableField::Value(include.clone()));
if let Some(profiles) = &original_toml.profile {
let cli_unstable = gctx.cli_unstable();
@ -1073,6 +1064,16 @@ pub fn to_real_manifest(
.map(|t| CompileTarget::new(&*t))
.transpose()?
.map(CompileKind::Target);
let include = package
.resolved_include()
.expect("previously resolved")
.cloned()
.unwrap_or_default();
let exclude = package
.resolved_exclude()
.expect("previously resolved")
.cloned()
.unwrap_or_default();
let custom_metadata = package.metadata.clone();
let resolved_toml = manifest::TomlManifest {
cargo_features: original_toml.cargo_features.clone(),