mirror of
https://github.com/rust-lang/cargo
synced 2024-08-27 19:29:21 +00:00
refactor(toml): Rely on resolved readme
This commit is contained in:
parent
c62a559d82
commit
d435d0e72a
|
@ -221,6 +221,18 @@ impl TomlPackage {
|
||||||
.map(|v| v.resolved())
|
.map(|v| v.resolved())
|
||||||
.transpose()
|
.transpose()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn resolved_readme(&self) -> Result<Option<&String>, UnresolvedError> {
|
||||||
|
self.readme
|
||||||
|
.as_ref()
|
||||||
|
.map(|v| {
|
||||||
|
v.resolved().and_then(|sb| match sb {
|
||||||
|
StringOrBool::Bool(_) => Err(UnresolvedError),
|
||||||
|
StringOrBool::String(value) => Ok(value),
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.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.
|
||||||
|
|
|
@ -9,8 +9,8 @@ use crate::AlreadyPrintedError;
|
||||||
use anyhow::{anyhow, bail, Context as _};
|
use anyhow::{anyhow, bail, Context as _};
|
||||||
use cargo_platform::Platform;
|
use cargo_platform::Platform;
|
||||||
use cargo_util::paths;
|
use cargo_util::paths;
|
||||||
use cargo_util_schemas::manifest::RustVersion;
|
|
||||||
use cargo_util_schemas::manifest::{self, TomlManifest};
|
use cargo_util_schemas::manifest::{self, TomlManifest};
|
||||||
|
use cargo_util_schemas::manifest::{RustVersion, StringOrBool};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use lazycell::LazyCell;
|
use lazycell::LazyCell;
|
||||||
use pathdiff::diff_paths;
|
use pathdiff::diff_paths;
|
||||||
|
@ -580,6 +580,16 @@ pub fn to_real_manifest(
|
||||||
.map(|value| field_inherit_with(value, "documentation", || inherit()?.documentation()))
|
.map(|value| field_inherit_with(value, "documentation", || inherit()?.documentation()))
|
||||||
.transpose()?
|
.transpose()?
|
||||||
.map(manifest::InheritableField::Value);
|
.map(manifest::InheritableField::Value);
|
||||||
|
package.readme = readme_for_package(
|
||||||
|
package_root,
|
||||||
|
package
|
||||||
|
.readme
|
||||||
|
.clone()
|
||||||
|
.map(|value| field_inherit_with(value, "readme", || inherit()?.readme(package_root)))
|
||||||
|
.transpose()?
|
||||||
|
.as_ref(),
|
||||||
|
)
|
||||||
|
.map(|s| manifest::InheritableField::Value(StringOrBool::String(s)));
|
||||||
|
|
||||||
let rust_version = package
|
let rust_version = package
|
||||||
.resolved_rust_version()
|
.resolved_rust_version()
|
||||||
|
@ -891,15 +901,10 @@ pub fn to_real_manifest(
|
||||||
.resolved_documentation()
|
.resolved_documentation()
|
||||||
.expect("previously resolved")
|
.expect("previously resolved")
|
||||||
.cloned(),
|
.cloned(),
|
||||||
readme: readme_for_package(
|
readme: package
|
||||||
package_root,
|
.resolved_readme()
|
||||||
package
|
.expect("previously resolved")
|
||||||
.readme
|
.cloned(),
|
||||||
.clone()
|
|
||||||
.map(|mw| field_inherit_with(mw, "readme", || inherit()?.readme(package_root)))
|
|
||||||
.transpose()?
|
|
||||||
.as_ref(),
|
|
||||||
),
|
|
||||||
authors: package
|
authors: package
|
||||||
.authors
|
.authors
|
||||||
.clone()
|
.clone()
|
||||||
|
@ -942,10 +947,6 @@ pub fn to_real_manifest(
|
||||||
links: package.links.clone(),
|
links: package.links.clone(),
|
||||||
rust_version: rust_version.clone(),
|
rust_version: rust_version.clone(),
|
||||||
};
|
};
|
||||||
package.readme = metadata
|
|
||||||
.readme
|
|
||||||
.clone()
|
|
||||||
.map(|readme| manifest::InheritableField::Value(manifest::StringOrBool::String(readme)));
|
|
||||||
package.authors = package
|
package.authors = package
|
||||||
.authors
|
.authors
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
|
Loading…
Reference in a new issue