Skip to content

Commit 28e7b2b

Browse files
committed
Auto merge of #13701 - epage:refactor, r=weihanglo
refactor(toml): Decouple target discovery from Target creation ### What does this PR try to resolve? This builds on #13693 so that the resolving of targets is easier to pull out into `resolve_toml` in prep for fixing #13456 ### How should we test and review this PR? ### Additional information
2 parents 1570666 + ff41868 commit 28e7b2b

File tree

3 files changed

+290
-209
lines changed

3 files changed

+290
-209
lines changed

src/cargo/util/toml/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use crate::util::{self, context::ConfigRelativePath, GlobalContext, IntoUrl, Opt
3232
mod embedded;
3333
mod targets;
3434

35-
use self::targets::targets;
35+
use self::targets::to_targets;
3636

3737
/// See also `bin/cargo/commands/run.rs`s `is_manifest_command`
3838
pub fn is_embedded(path: &Path) -> bool {
@@ -476,7 +476,7 @@ fn resolve_package_toml<'a>(
476476
.map(|value| field_inherit_with(value, "documentation", || inherit()?.documentation()))
477477
.transpose()?
478478
.map(manifest::InheritableField::Value),
479-
readme: readme_for_package(
479+
readme: resolve_package_readme(
480480
package_root,
481481
original_package
482482
.readme
@@ -530,7 +530,7 @@ fn resolve_package_toml<'a>(
530530
}
531531

532532
/// Returns the name of the README file for a [`manifest::TomlPackage`].
533-
fn readme_for_package(
533+
fn resolve_package_readme(
534534
package_root: &Path,
535535
readme: Option<&manifest::StringOrBool>,
536536
) -> Option<String> {
@@ -764,7 +764,7 @@ impl InheritableFields {
764764

765765
/// Gets the field `workspace.package.readme`.
766766
fn readme(&self, package_root: &Path) -> CargoResult<manifest::StringOrBool> {
767-
let Some(readme) = readme_for_package(
767+
let Some(readme) = resolve_package_readme(
768768
self._ws_root.as_path(),
769769
self.package.as_ref().and_then(|p| p.readme.as_ref()),
770770
) else {
@@ -1065,7 +1065,7 @@ fn to_real_manifest(
10651065
// If we have no lib at all, use the inferred lib, if available.
10661066
// If we have a lib with a path, we're done.
10671067
// If we have a lib with no path, use the inferred lib or else the package name.
1068-
let targets = targets(
1068+
let targets = to_targets(
10691069
&features,
10701070
&resolved_toml,
10711071
package_name,

0 commit comments

Comments
 (0)