diff --git a/Cargo.lock b/Cargo.lock index 2be61a658aa..a5b3703ba09 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -461,7 +461,7 @@ dependencies = [ [[package]] name = "cargo-util-schemas" -version = "0.5.1" +version = "0.6.0" dependencies = [ "semver", "serde", diff --git a/Cargo.toml b/Cargo.toml index fc47f7ade37..9dc40f90a8e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,7 +33,7 @@ cargo-platform = { path = "crates/cargo-platform", version = "0.1.5" } cargo-test-macro = { version = "0.3.0", path = "crates/cargo-test-macro" } cargo-test-support = { version = "0.4.0", path = "crates/cargo-test-support" } cargo-util = { version = "0.2.14", path = "crates/cargo-util" } -cargo-util-schemas = { version = "0.5.0", path = "crates/cargo-util-schemas" } +cargo-util-schemas = { version = "0.6.0", path = "crates/cargo-util-schemas" } cargo_metadata = "0.18.1" clap = "4.5.11" color-print = "0.3.6" diff --git a/crates/cargo-util-schemas/Cargo.toml b/crates/cargo-util-schemas/Cargo.toml index f960213f7de..b95026ac3be 100644 --- a/crates/cargo-util-schemas/Cargo.toml +++ b/crates/cargo-util-schemas/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo-util-schemas" -version = "0.5.1" +version = "0.6.0" rust-version = "1.80" # MSRV:1 edition.workspace = true license.workspace = true diff --git a/crates/cargo-util-schemas/src/manifest/mod.rs b/crates/cargo-util-schemas/src/manifest/mod.rs index fe954f0f4ca..df0bb51dcfd 100644 --- a/crates/cargo-util-schemas/src/manifest/mod.rs +++ b/crates/cargo-util-schemas/src/manifest/mod.rs @@ -106,8 +106,8 @@ impl TomlManifest { self.features.as_ref() } - pub fn resolved_lints(&self) -> Result, UnresolvedError> { - self.lints.as_ref().map(|l| l.resolved()).transpose() + pub fn normalized_lints(&self) -> Result, UnresolvedError> { + self.lints.as_ref().map(|l| l.normalized()).transpose() } } @@ -237,23 +237,26 @@ impl TomlPackage { } } - pub fn resolved_edition(&self) -> Result, UnresolvedError> { - self.edition.as_ref().map(|v| v.resolved()).transpose() + pub fn normalized_edition(&self) -> Result, UnresolvedError> { + self.edition.as_ref().map(|v| v.normalized()).transpose() } - pub fn resolved_rust_version(&self) -> Result, UnresolvedError> { - self.rust_version.as_ref().map(|v| v.resolved()).transpose() + pub fn normalized_rust_version(&self) -> Result, UnresolvedError> { + self.rust_version + .as_ref() + .map(|v| v.normalized()) + .transpose() } - pub fn resolved_version(&self) -> Result, UnresolvedError> { - self.version.as_ref().map(|v| v.resolved()).transpose() + pub fn normalized_version(&self) -> Result, UnresolvedError> { + self.version.as_ref().map(|v| v.normalized()).transpose() } - pub fn resolved_authors(&self) -> Result>, UnresolvedError> { - self.authors.as_ref().map(|v| v.resolved()).transpose() + pub fn normalized_authors(&self) -> Result>, UnresolvedError> { + self.authors.as_ref().map(|v| v.normalized()).transpose() } - pub fn resolved_build(&self) -> Result, UnresolvedError> { + pub fn normalized_build(&self) -> Result, UnresolvedError> { let readme = self.build.as_ref().ok_or(UnresolvedError)?; match readme { StringOrBool::Bool(false) => Ok(None), @@ -262,60 +265,66 @@ impl TomlPackage { } } - pub fn resolved_exclude(&self) -> Result>, UnresolvedError> { - self.exclude.as_ref().map(|v| v.resolved()).transpose() + pub fn normalized_exclude(&self) -> Result>, UnresolvedError> { + self.exclude.as_ref().map(|v| v.normalized()).transpose() } - pub fn resolved_include(&self) -> Result>, UnresolvedError> { - self.include.as_ref().map(|v| v.resolved()).transpose() + pub fn normalized_include(&self) -> Result>, UnresolvedError> { + self.include.as_ref().map(|v| v.normalized()).transpose() } - pub fn resolved_publish(&self) -> Result, UnresolvedError> { - self.publish.as_ref().map(|v| v.resolved()).transpose() + pub fn normalized_publish(&self) -> Result, UnresolvedError> { + self.publish.as_ref().map(|v| v.normalized()).transpose() } - pub fn resolved_description(&self) -> Result, UnresolvedError> { - self.description.as_ref().map(|v| v.resolved()).transpose() + pub fn normalized_description(&self) -> Result, UnresolvedError> { + self.description + .as_ref() + .map(|v| v.normalized()) + .transpose() } - pub fn resolved_homepage(&self) -> Result, UnresolvedError> { - self.homepage.as_ref().map(|v| v.resolved()).transpose() + pub fn normalized_homepage(&self) -> Result, UnresolvedError> { + self.homepage.as_ref().map(|v| v.normalized()).transpose() } - pub fn resolved_documentation(&self) -> Result, UnresolvedError> { + pub fn normalized_documentation(&self) -> Result, UnresolvedError> { self.documentation .as_ref() - .map(|v| v.resolved()) + .map(|v| v.normalized()) .transpose() } - pub fn resolved_readme(&self) -> Result, UnresolvedError> { + pub fn normalized_readme(&self) -> Result, UnresolvedError> { let readme = self.readme.as_ref().ok_or(UnresolvedError)?; - readme.resolved().and_then(|sb| match sb { + readme.normalized().and_then(|sb| match sb { StringOrBool::Bool(false) => Ok(None), StringOrBool::Bool(true) => Err(UnresolvedError), StringOrBool::String(value) => Ok(Some(value)), }) } - pub fn resolved_keywords(&self) -> Result>, UnresolvedError> { - self.keywords.as_ref().map(|v| v.resolved()).transpose() + pub fn normalized_keywords(&self) -> Result>, UnresolvedError> { + self.keywords.as_ref().map(|v| v.normalized()).transpose() } - pub fn resolved_categories(&self) -> Result>, UnresolvedError> { - self.categories.as_ref().map(|v| v.resolved()).transpose() + pub fn normalized_categories(&self) -> Result>, UnresolvedError> { + self.categories.as_ref().map(|v| v.normalized()).transpose() } - pub fn resolved_license(&self) -> Result, UnresolvedError> { - self.license.as_ref().map(|v| v.resolved()).transpose() + pub fn normalized_license(&self) -> Result, UnresolvedError> { + self.license.as_ref().map(|v| v.normalized()).transpose() } - pub fn resolved_license_file(&self) -> Result, UnresolvedError> { - self.license_file.as_ref().map(|v| v.resolved()).transpose() + pub fn normalized_license_file(&self) -> Result, UnresolvedError> { + self.license_file + .as_ref() + .map(|v| v.normalized()) + .transpose() } - pub fn resolved_repository(&self) -> Result, UnresolvedError> { - self.repository.as_ref().map(|v| v.resolved()).transpose() + pub fn normalized_repository(&self) -> Result, UnresolvedError> { + self.repository.as_ref().map(|v| v.normalized()).transpose() } } @@ -330,7 +339,7 @@ pub enum InheritableField { } impl InheritableField { - pub fn resolved(&self) -> Result<&T, UnresolvedError> { + pub fn normalized(&self) -> Result<&T, UnresolvedError> { self.as_value().ok_or(UnresolvedError) } @@ -634,7 +643,7 @@ impl InheritableDependency { } } - pub fn resolved(&self) -> Result<&TomlDependency, UnresolvedError> { + pub fn normalized(&self) -> Result<&TomlDependency, UnresolvedError> { match self { InheritableDependency::Value(d) => Ok(d), InheritableDependency::Inherit(_) => Err(UnresolvedError), @@ -1440,7 +1449,7 @@ pub struct InheritableLints { } impl InheritableLints { - pub fn resolved(&self) -> Result<&TomlLints, UnresolvedError> { + pub fn normalized(&self) -> Result<&TomlLints, UnresolvedError> { if self.workspace { Err(UnresolvedError) } else { diff --git a/src/cargo/core/compiler/fingerprint/mod.rs b/src/cargo/core/compiler/fingerprint/mod.rs index 6ffebd753cd..22ac87ba85e 100644 --- a/src/cargo/core/compiler/fingerprint/mod.rs +++ b/src/cargo/core/compiler/fingerprint/mod.rs @@ -1426,7 +1426,7 @@ fn calculate_normal( // HACK(#13975): duplicating the lookup logic here until `--check-cfg` is supported // on Cargo's MSRV and we can centralize the logic in `lints_to_rustflags` let mut lint_check_cfg = Vec::new(); - if let Ok(Some(lints)) = unit.pkg.manifest().resolved_toml().resolved_lints() { + if let Ok(Some(lints)) = unit.pkg.manifest().normalized_toml().normalized_lints() { if let Some(rust_lints) = lints.get("rust") { if let Some(unexpected_cfgs) = rust_lints.get("unexpected_cfgs") { if let Some(config) = unexpected_cfgs.config() { diff --git a/src/cargo/core/compiler/mod.rs b/src/cargo/core/compiler/mod.rs index a7b7e7b83d9..fe07c59945d 100644 --- a/src/cargo/core/compiler/mod.rs +++ b/src/cargo/core/compiler/mod.rs @@ -1355,7 +1355,7 @@ fn check_cfg_args(unit: &Unit) -> CargoResult> { ]; // Also include the custom arguments specified in `[lints.rust.unexpected_cfgs.check_cfg]` - if let Ok(Some(lints)) = unit.pkg.manifest().resolved_toml().resolved_lints() { + if let Ok(Some(lints)) = unit.pkg.manifest().normalized_toml().normalized_lints() { if let Some(rust_lints) = lints.get("rust") { if let Some(unexpected_cfgs) = rust_lints.get("unexpected_cfgs") { if let Some(config) = unexpected_cfgs.config() { diff --git a/src/cargo/core/manifest.rs b/src/cargo/core/manifest.rs index a45a26a765f..d63dbd61de3 100644 --- a/src/cargo/core/manifest.rs +++ b/src/cargo/core/manifest.rs @@ -64,7 +64,7 @@ pub struct Manifest { contents: Rc, document: Rc>, original_toml: Rc, - resolved_toml: Rc, + normalized_toml: Rc, summary: Summary, // this form of manifest: @@ -110,7 +110,7 @@ pub struct VirtualManifest { contents: Rc, document: Rc>, original_toml: Rc, - resolved_toml: Rc, + normalized_toml: Rc, // this form of manifest: replace: Vec<(PackageIdSpec, Dependency)>, @@ -422,7 +422,7 @@ impl Manifest { contents: Rc, document: Rc>, original_toml: Rc, - resolved_toml: Rc, + normalized_toml: Rc, summary: Summary, default_kind: Option, @@ -451,7 +451,7 @@ impl Manifest { contents, document, original_toml, - resolved_toml, + normalized_toml, summary, default_kind, @@ -483,9 +483,9 @@ impl Manifest { pub fn contents(&self) -> &str { self.contents.as_str() } - /// See [`Manifest::resolved_toml`] for what "resolved" means - pub fn to_resolved_contents(&self) -> CargoResult { - let toml = toml::to_string_pretty(self.resolved_toml())?; + /// See [`Manifest::normalized_toml`] for what "normalized" means + pub fn to_normalized_contents(&self) -> CargoResult { + let toml = toml::to_string_pretty(self.normalized_toml())?; Ok(format!("{}\n{}", MANIFEST_PREAMBLE, toml)) } /// Collection of spans for the original TOML @@ -502,8 +502,8 @@ impl Manifest { /// useful for the operation of cargo, including /// - workspace inheritance /// - target discovery - pub fn resolved_toml(&self) -> &TomlManifest { - &self.resolved_toml + pub fn normalized_toml(&self) -> &TomlManifest { + &self.normalized_toml } pub fn summary(&self) -> &Summary { &self.summary @@ -553,7 +553,7 @@ impl Manifest { &self.warnings } pub fn profiles(&self) -> Option<&TomlProfiles> { - self.resolved_toml.profile.as_ref() + self.normalized_toml.profile.as_ref() } pub fn publish(&self) -> &Option> { &self.publish @@ -664,7 +664,7 @@ impl VirtualManifest { contents: Rc, document: Rc>, original_toml: Rc, - resolved_toml: Rc, + normalized_toml: Rc, replace: Vec<(PackageIdSpec, Dependency)>, patch: HashMap>, workspace: WorkspaceConfig, @@ -675,7 +675,7 @@ impl VirtualManifest { contents, document, original_toml, - resolved_toml, + normalized_toml, replace, patch, workspace, @@ -698,8 +698,8 @@ impl VirtualManifest { &self.original_toml } /// The [`TomlManifest`] with all fields expanded - pub fn resolved_toml(&self) -> &TomlManifest { - &self.resolved_toml + pub fn normalized_toml(&self) -> &TomlManifest { + &self.normalized_toml } pub fn replace(&self) -> &[(PackageIdSpec, Dependency)] { @@ -715,7 +715,7 @@ impl VirtualManifest { } pub fn profiles(&self) -> Option<&TomlProfiles> { - self.resolved_toml.profile.as_ref() + self.normalized_toml.profile.as_ref() } pub fn warnings_mut(&mut self) -> &mut Warnings { diff --git a/src/cargo/core/workspace.rs b/src/cargo/core/workspace.rs index 65b14233315..0e538c698e1 100644 --- a/src/cargo/core/workspace.rs +++ b/src/cargo/core/workspace.rs @@ -1066,7 +1066,7 @@ impl<'gctx> Workspace<'gctx> { ); self.gctx.shell().warn(&msg) }; - if manifest.resolved_toml().has_profiles() { + if manifest.normalized_toml().has_profiles() { emit_warning("profiles")?; } if !manifest.replace().is_empty() { @@ -1191,7 +1191,7 @@ impl<'gctx> Workspace<'gctx> { let mut error_count = 0; let toml_lints = pkg .manifest() - .resolved_toml() + .normalized_toml() .lints .clone() .map(|lints| lints.lints) diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs index 459e780f32f..ab4ceeb4199 100644 --- a/src/cargo/ops/cargo_package.rs +++ b/src/cargo/ops/cargo_package.rs @@ -924,7 +924,7 @@ fn tar( } FileContents::Generated(generated_kind) => { let contents = match generated_kind { - GeneratedFile::Manifest => publish_pkg.manifest().to_resolved_contents()?, + GeneratedFile::Manifest => publish_pkg.manifest().to_normalized_contents()?, GeneratedFile::Lockfile => build_lock(ws, &publish_pkg, local_reg)?, GeneratedFile::VcsInfo(ref s) => serde_json::to_string_pretty(s)?, }; diff --git a/src/cargo/ops/fix.rs b/src/cargo/ops/fix.rs index df354b36e4b..26c49088f81 100644 --- a/src/cargo/ops/fix.rs +++ b/src/cargo/ops/fix.rs @@ -443,7 +443,7 @@ fn add_feature_for_unused_deps( let manifest = pkg.manifest(); let activated_opt_deps = manifest - .resolved_toml() + .normalized_toml() .features() .map(|map| { map.values() @@ -479,7 +479,7 @@ fn add_feature_for_unused_deps( // only way to guarantee an optional dependency is available for use. // // The way we avoid implicitly creating features in Edition2024 is we remove the - // dependency from `resolved_toml` if there is no `dep:` syntax as that is the only + // dependency from `normalized_toml` if there is no `dep:` syntax as that is the only // syntax that suppresses the creation of the implicit feature. for (feature_name, activations) in features.iter_mut() { let Some(activations) = activations.as_array_mut() else { diff --git a/src/cargo/ops/registry/publish.rs b/src/cargo/ops/registry/publish.rs index 592a1cb0765..7fd3acfbec7 100644 --- a/src/cargo/ops/registry/publish.rs +++ b/src/cargo/ops/registry/publish.rs @@ -411,7 +411,7 @@ pub(crate) fn prepare_transmit( } } - let string_features = match manifest.resolved_toml().features() { + let string_features = match manifest.normalized_toml().features() { Some(features) => features .iter() .map(|(feat, values)| { diff --git a/src/cargo/ops/vendor.rs b/src/cargo/ops/vendor.rs index f319dedce38..a060b3cd6db 100644 --- a/src/cargo/ops/vendor.rs +++ b/src/cargo/ops/vendor.rs @@ -360,7 +360,7 @@ fn cp_sources( let cksum = if dst.file_name() == Some(OsStr::new("Cargo.toml")) && pkg.package_id().source_id().is_git() { - let contents = pkg.manifest().to_resolved_contents()?; + let contents = pkg.manifest().to_normalized_contents()?; copy_and_checksum( &dst, &mut dst_opts, diff --git a/src/cargo/sources/path.rs b/src/cargo/sources/path.rs index 85036c8101f..4159da35275 100644 --- a/src/cargo/sources/path.rs +++ b/src/cargo/sources/path.rs @@ -880,14 +880,14 @@ fn read_packages( fn nested_paths(manifest: &Manifest) -> Vec { let mut nested_paths = Vec::new(); - let resolved = manifest.resolved_toml(); - let dependencies = resolved + let normalized = manifest.normalized_toml(); + let dependencies = normalized .dependencies .iter() - .chain(resolved.build_dependencies()) - .chain(resolved.dev_dependencies()) + .chain(normalized.build_dependencies()) + .chain(normalized.dev_dependencies()) .chain( - resolved + normalized .target .as_ref() .into_iter() diff --git a/src/cargo/util/lints.rs b/src/cargo/util/lints.rs index f443fdd6ec2..4d1b5b6de88 100644 --- a/src/cargo/util/lints.rs +++ b/src/cargo/util/lints.rs @@ -456,7 +456,7 @@ pub fn check_im_a_teapot( } if manifest - .resolved_toml() + .normalized_toml() .package() .is_some_and(|p| p.im_a_teapot.is_some()) { @@ -560,7 +560,7 @@ pub fn check_implicit_features( } let activated_opt_deps = manifest - .resolved_toml() + .normalized_toml() .features() .map(|map| { map.values() diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index 76892b9d773..35318991789 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -81,7 +81,7 @@ pub fn read_manifest( .borrow_mut() .insert(package_root.to_owned(), ws_root_config.clone()); } - let resolved_toml = resolve_toml( + let normalized_toml = normalize_toml( &original_toml, &features, &workspace_config, @@ -91,12 +91,12 @@ pub fn read_manifest( &mut errors, )?; - if resolved_toml.package().is_some() { + if normalized_toml.package().is_some() { to_real_manifest( contents, document, original_toml, - resolved_toml, + normalized_toml, features, workspace_config, source_id, @@ -106,12 +106,12 @@ pub fn read_manifest( &mut errors, ) .map(EitherManifest::Real) - } else if resolved_toml.workspace.is_some() { + } else if normalized_toml.workspace.is_some() { to_virtual_manifest( contents, document, original_toml, - resolved_toml, + normalized_toml, features, workspace_config, source_id, @@ -240,30 +240,30 @@ fn to_workspace_config( } fn to_workspace_root_config( - resolved_toml: &manifest::TomlWorkspace, + normalized_toml: &manifest::TomlWorkspace, manifest_file: &Path, ) -> WorkspaceRootConfig { let package_root = manifest_file.parent().unwrap(); let inheritable = InheritableFields { - package: resolved_toml.package.clone(), - dependencies: resolved_toml.dependencies.clone(), - lints: resolved_toml.lints.clone(), + package: normalized_toml.package.clone(), + dependencies: normalized_toml.dependencies.clone(), + lints: normalized_toml.lints.clone(), _ws_root: package_root.to_owned(), }; let ws_root_config = WorkspaceRootConfig::new( package_root, - &resolved_toml.members, - &resolved_toml.default_members, - &resolved_toml.exclude, + &normalized_toml.members, + &normalized_toml.default_members, + &normalized_toml.exclude, &Some(inheritable), - &resolved_toml.metadata, + &normalized_toml.metadata, ); ws_root_config } -/// See [`Manifest::resolved_toml`] for more details +/// See [`Manifest::normalized_toml`] for more details #[tracing::instrument(skip_all)] -fn resolve_toml( +fn normalize_toml( original_toml: &manifest::TomlManifest, features: &Features, workspace_config: &WorkspaceConfig, @@ -278,7 +278,7 @@ fn resolve_toml( } } - let mut resolved_toml = manifest::TomlManifest { + let mut normalized_toml = manifest::TomlManifest { cargo_features: original_toml.cargo_features.clone(), package: None, project: None, @@ -314,26 +314,26 @@ fn resolve_toml( if let Some(original_package) = original_toml.package() { let package_name = &original_package.name; - let resolved_package = - resolve_package_toml(original_package, features, package_root, &inherit)?; - let edition = resolved_package - .resolved_edition() - .expect("previously resolved") + let normalized_package = + normalize_package_toml(original_package, features, package_root, &inherit)?; + let edition = normalized_package + .normalized_edition() + .expect("previously normalized") .map_or(Edition::default(), |e| { Edition::from_str(&e).unwrap_or_default() }); - resolved_toml.package = Some(resolved_package); + normalized_toml.package = Some(normalized_package); - resolved_toml.features = resolve_features(original_toml.features.as_ref())?; + normalized_toml.features = normalize_features(original_toml.features.as_ref())?; - resolved_toml.lib = targets::resolve_lib( + normalized_toml.lib = targets::normalize_lib( original_toml.lib.as_ref(), package_root, &original_package.name, edition, warnings, )?; - resolved_toml.bin = Some(targets::resolve_bins( + normalized_toml.bin = Some(targets::normalize_bins( original_toml.bin.as_ref(), package_root, &original_package.name, @@ -341,9 +341,9 @@ fn resolve_toml( original_package.autobins, warnings, errors, - resolved_toml.lib.is_some(), + normalized_toml.lib.is_some(), )?); - resolved_toml.example = Some(targets::resolve_examples( + normalized_toml.example = Some(targets::normalize_examples( original_toml.example.as_ref(), package_root, edition, @@ -351,7 +351,7 @@ fn resolve_toml( warnings, errors, )?); - resolved_toml.test = Some(targets::resolve_tests( + normalized_toml.test = Some(targets::normalize_tests( original_toml.test.as_ref(), package_root, edition, @@ -359,7 +359,7 @@ fn resolve_toml( warnings, errors, )?); - resolved_toml.bench = Some(targets::resolve_benches( + normalized_toml.bench = Some(targets::normalize_benches( original_toml.bench.as_ref(), package_root, edition, @@ -368,7 +368,7 @@ fn resolve_toml( errors, )?); - let activated_opt_deps = resolved_toml + let activated_opt_deps = normalized_toml .features .as_ref() .map(|map| { @@ -382,7 +382,7 @@ fn resolve_toml( }) .unwrap_or_default(); - resolved_toml.dependencies = resolve_dependencies( + normalized_toml.dependencies = normalize_dependencies( gctx, edition, &features, @@ -402,7 +402,7 @@ fn resolve_toml( edition, warnings, )?; - resolved_toml.dev_dependencies = resolve_dependencies( + normalized_toml.dev_dependencies = normalize_dependencies( gctx, edition, &features, @@ -422,7 +422,7 @@ fn resolve_toml( edition, warnings, )?; - resolved_toml.build_dependencies = resolve_dependencies( + normalized_toml.build_dependencies = normalize_dependencies( gctx, edition, &features, @@ -433,9 +433,9 @@ fn resolve_toml( package_root, warnings, )?; - let mut resolved_target = BTreeMap::new(); + let mut normalized_target = BTreeMap::new(); for (name, platform) in original_toml.target.iter().flatten() { - let resolved_dependencies = resolve_dependencies( + let normalized_dependencies = normalize_dependencies( gctx, edition, &features, @@ -455,7 +455,7 @@ fn resolve_toml( edition, warnings, )?; - let resolved_dev_dependencies = resolve_dependencies( + let normalized_dev_dependencies = normalize_dependencies( gctx, edition, &features, @@ -475,7 +475,7 @@ fn resolve_toml( edition, warnings, )?; - let resolved_build_dependencies = resolve_dependencies( + let normalized_build_dependencies = normalize_dependencies( gctx, edition, &features, @@ -486,47 +486,47 @@ fn resolve_toml( package_root, warnings, )?; - resolved_target.insert( + normalized_target.insert( name.clone(), manifest::TomlPlatform { - dependencies: resolved_dependencies, - build_dependencies: resolved_build_dependencies, + dependencies: normalized_dependencies, + build_dependencies: normalized_build_dependencies, build_dependencies2: None, - dev_dependencies: resolved_dev_dependencies, + dev_dependencies: normalized_dev_dependencies, dev_dependencies2: None, }, ); } - resolved_toml.target = (!resolved_target.is_empty()).then_some(resolved_target); + normalized_toml.target = (!normalized_target.is_empty()).then_some(normalized_target); - let resolved_lints = original_toml + let normalized_lints = original_toml .lints .clone() .map(|value| lints_inherit_with(value, || inherit()?.lints())) .transpose()?; - resolved_toml.lints = resolved_lints.map(|lints| manifest::InheritableLints { + normalized_toml.lints = normalized_lints.map(|lints| manifest::InheritableLints { workspace: false, lints, }); - resolved_toml.badges = original_toml.badges.clone(); + normalized_toml.badges = original_toml.badges.clone(); } else { for field in original_toml.requires_package() { bail!("this virtual manifest specifies a `{field}` section, which is not allowed"); } } - Ok(resolved_toml) + Ok(normalized_toml) } #[tracing::instrument(skip_all)] -fn resolve_package_toml<'a>( +fn normalize_package_toml<'a>( original_package: &manifest::TomlPackage, features: &Features, package_root: &Path, inherit: &dyn Fn() -> CargoResult<&'a InheritableFields>, ) -> CargoResult> { - let resolved_package = manifest::TomlPackage { + let normalized_package = manifest::TomlPackage { edition: original_package .edition .clone() @@ -552,7 +552,7 @@ fn resolve_package_toml<'a>( .map(|value| field_inherit_with(value, "authors", || inherit()?.authors())) .transpose()? .map(manifest::InheritableField::Value), - build: targets::resolve_build(original_package.build.as_ref(), package_root), + build: targets::normalize_build(original_package.build.as_ref(), package_root), metabuild: original_package.metabuild.clone(), default_target: original_package.default_target.clone(), forced_target: original_package.forced_target.clone(), @@ -600,7 +600,7 @@ fn resolve_package_toml<'a>( .map(|value| field_inherit_with(value, "documentation", || inherit()?.documentation())) .transpose()? .map(manifest::InheritableField::Value), - readme: resolve_package_readme( + readme: normalize_package_readme( package_root, original_package .readme @@ -654,15 +654,15 @@ fn resolve_package_toml<'a>( _invalid_cargo_features: Default::default(), }; - if resolved_package.resolver.as_deref() == Some("3") { + if normalized_package.resolver.as_deref() == Some("3") { features.require(Feature::edition2024())?; } - Ok(Box::new(resolved_package)) + Ok(Box::new(normalized_package)) } /// Returns the name of the README file for a [`manifest::TomlPackage`]. -fn resolve_package_readme( +fn normalize_package_readme( package_root: &Path, readme: Option<&manifest::StringOrBool>, ) -> Option { @@ -691,18 +691,18 @@ fn default_readme_from_package_root(package_root: &Path) -> Option { } #[tracing::instrument(skip_all)] -fn resolve_features( +fn normalize_features( original_features: Option<&BTreeMap>>, ) -> CargoResult>>> { - let Some(resolved_features) = original_features.cloned() else { + let Some(normalized_features) = original_features.cloned() else { return Ok(None); }; - Ok(Some(resolved_features)) + Ok(Some(normalized_features)) } #[tracing::instrument(skip_all)] -fn resolve_dependencies<'a>( +fn normalize_dependencies<'a>( gctx: &GlobalContext, edition: Edition, features: &Features, @@ -788,7 +788,7 @@ fn resolve_dependencies<'a>( fn load_inheritable_fields( gctx: &GlobalContext, - resolved_path: &Path, + normalized_path: &Path, workspace_config: &WorkspaceConfig, ) -> CargoResult { match workspace_config { @@ -796,7 +796,7 @@ fn load_inheritable_fields( WorkspaceConfig::Member { root: Some(ref path_to_root), } => { - let path = resolved_path + let path = normalized_path .parent() .unwrap() .join(path_to_root) @@ -805,7 +805,7 @@ fn load_inheritable_fields( inheritable_from_path(gctx, root_path) } WorkspaceConfig::Member { root: None } => { - match find_workspace_root(&resolved_path, gctx)? { + match find_workspace_root(&normalized_path, gctx)? { Some(path_to_root) => inheritable_from_path(gctx, path_to_root), None => Err(anyhow!("failed to find a workspace root")), } @@ -931,7 +931,7 @@ impl InheritableFields { /// Gets the field `workspace.package.readme`. fn readme(&self, package_root: &Path) -> CargoResult { - let Some(readme) = resolve_package_readme( + let Some(readme) = normalize_package_readme( self._ws_root.as_path(), self.package.as_ref().and_then(|p| p.readme.as_ref()), ) else { @@ -1090,7 +1090,7 @@ fn to_real_manifest( contents: String, document: toml_edit::ImDocument, original_toml: manifest::TomlManifest, - resolved_toml: manifest::TomlManifest, + normalized_toml: manifest::TomlManifest, features: Features, workspace_config: WorkspaceConfig, source_id: SourceId, @@ -1117,17 +1117,17 @@ fn to_real_manifest( features.require(Feature::open_namespaces())?; } - let resolved_package = resolved_toml + let normalized_package = normalized_toml .package() .expect("previously verified to have a `[package]`"); - let rust_version = resolved_package - .resolved_rust_version() - .expect("previously resolved") + let rust_version = normalized_package + .normalized_rust_version() + .expect("previously normalized") .cloned(); - let edition = if let Some(edition) = resolved_package - .resolved_edition() - .expect("previously resolved") + let edition = if let Some(edition) = normalized_package + .normalized_edition() + .expect("previously normalized") { let edition: Edition = edition .parse() @@ -1210,13 +1210,13 @@ fn to_real_manifest( } } - if resolved_package.metabuild.is_some() { + if normalized_package.metabuild.is_some() { features.require(Feature::metabuild())?; } let resolve_behavior = match ( - resolved_package.resolver.as_ref(), - resolved_toml + normalized_package.resolver.as_ref(), + normalized_toml .workspace .as_ref() .and_then(|ws| ws.resolver.as_ref()), @@ -1234,10 +1234,10 @@ fn to_real_manifest( let targets = to_targets( &features, &original_toml, - &resolved_toml, + &normalized_toml, package_root, edition, - &resolved_package.metabuild, + &normalized_package.metabuild, warnings, )?; @@ -1265,7 +1265,7 @@ fn to_real_manifest( }) } - if let Some(links) = &resolved_package.links { + if let Some(links) = &normalized_package.links { if !targets.iter().any(|t| t.is_custom_build()) { bail!("package specifies that it links to `{links}` but does not have a custom build script") } @@ -1318,18 +1318,22 @@ fn to_real_manifest( platform: None, root: package_root, }; - gather_dependencies(&mut manifest_ctx, resolved_toml.dependencies.as_ref(), None)?; gather_dependencies( &mut manifest_ctx, - resolved_toml.dev_dependencies(), + normalized_toml.dependencies.as_ref(), + None, + )?; + gather_dependencies( + &mut manifest_ctx, + normalized_toml.dev_dependencies(), Some(DepKind::Development), )?; gather_dependencies( &mut manifest_ctx, - resolved_toml.build_dependencies(), + normalized_toml.build_dependencies(), Some(DepKind::Build), )?; - for (name, platform) in resolved_toml.target.iter().flatten() { + for (name, platform) in normalized_toml.target.iter().flatten() { manifest_ctx.platform = Some(name.parse()?); gather_dependencies(&mut manifest_ctx, platform.dependencies.as_ref(), None)?; gather_dependencies( @@ -1343,8 +1347,8 @@ fn to_real_manifest( Some(DepKind::Development), )?; } - let replace = replace(&resolved_toml, &mut manifest_ctx)?; - let patch = patch(&resolved_toml, &mut manifest_ctx)?; + let replace = replace(&normalized_toml, &mut manifest_ctx)?; + let patch = patch(&normalized_toml, &mut manifest_ctx)?; { let mut names_sources = BTreeMap::new(); @@ -1363,78 +1367,80 @@ fn to_real_manifest( } verify_lints( - resolved_toml.resolved_lints().expect("previously resolved"), + normalized_toml + .normalized_lints() + .expect("previously normalized"), gctx, warnings, )?; let default = manifest::TomlLints::default(); let rustflags = lints_to_rustflags( - resolved_toml - .resolved_lints() - .expect("previously resolved") + normalized_toml + .normalized_lints() + .expect("previously normalized") .unwrap_or(&default), ); let metadata = ManifestMetadata { - description: resolved_package - .resolved_description() - .expect("previously resolved") + description: normalized_package + .normalized_description() + .expect("previously normalized") .cloned(), - homepage: resolved_package - .resolved_homepage() - .expect("previously resolved") + homepage: normalized_package + .normalized_homepage() + .expect("previously normalized") .cloned(), - documentation: resolved_package - .resolved_documentation() - .expect("previously resolved") + documentation: normalized_package + .normalized_documentation() + .expect("previously normalized") .cloned(), - readme: resolved_package - .resolved_readme() - .expect("previously resolved") + readme: normalized_package + .normalized_readme() + .expect("previously normalized") .cloned(), - authors: resolved_package - .resolved_authors() - .expect("previously resolved") + authors: normalized_package + .normalized_authors() + .expect("previously normalized") .cloned() .unwrap_or_default(), - license: resolved_package - .resolved_license() - .expect("previously resolved") + license: normalized_package + .normalized_license() + .expect("previously normalized") .cloned(), - license_file: resolved_package - .resolved_license_file() - .expect("previously resolved") + license_file: normalized_package + .normalized_license_file() + .expect("previously normalized") .cloned(), - repository: resolved_package - .resolved_repository() - .expect("previously resolved") + repository: normalized_package + .normalized_repository() + .expect("previously normalized") .cloned(), - keywords: resolved_package - .resolved_keywords() - .expect("previously resolved") + keywords: normalized_package + .normalized_keywords() + .expect("previously normalized") .cloned() .unwrap_or_default(), - categories: resolved_package - .resolved_categories() - .expect("previously resolved") + categories: normalized_package + .normalized_categories() + .expect("previously normalized") .cloned() .unwrap_or_default(), - badges: resolved_toml.badges.clone().unwrap_or_default(), - links: resolved_package.links.clone(), + badges: normalized_toml.badges.clone().unwrap_or_default(), + links: normalized_package.links.clone(), rust_version: rust_version.clone(), }; - if let Some(profiles) = &resolved_toml.profile { + if let Some(profiles) = &normalized_toml.profile { let cli_unstable = gctx.cli_unstable(); validate_profiles(profiles, cli_unstable, &features, warnings)?; } - let version = resolved_package - .resolved_version() - .expect("previously resolved"); - let publish = match resolved_package - .resolved_publish() - .expect("previously resolved") + let version = normalized_package + .normalized_version() + .expect("previously normalized"); + let publish = match normalized_package + .normalized_publish() + .expect("previously normalized") { Some(manifest::VecStringOrBool::VecString(ref vecstring)) => Some(vecstring.clone()), Some(manifest::VecStringOrBool::Bool(false)) => Some(vec![]), @@ -1447,7 +1453,7 @@ fn to_real_manifest( } let pkgid = PackageId::new( - resolved_package.name.as_str().into(), + normalized_package.name.as_str().into(), version .cloned() .unwrap_or_else(|| semver::Version::new(0, 0, 0)), @@ -1457,7 +1463,7 @@ fn to_real_manifest( let summary = Summary::new( pkgid, deps, - &resolved_toml + &normalized_toml .features .as_ref() .unwrap_or(&Default::default()) @@ -1469,7 +1475,7 @@ fn to_real_manifest( ) }) .collect(), - resolved_package.links.as_deref(), + normalized_package.links.as_deref(), rust_version.clone(), ); // editon2024 stops exposing implicit features, which will strip weak optional dependencies from `dependencies`, @@ -1497,7 +1503,7 @@ fn to_real_manifest( ) } - if let Some(run) = &resolved_package.default_run { + if let Some(run) = &normalized_package.default_run { if !targets .iter() .filter(|t| t.is_bin()) @@ -1509,38 +1515,38 @@ fn to_real_manifest( } } - let default_kind = resolved_package + let default_kind = normalized_package .default_target .as_ref() .map(|t| CompileTarget::new(&*t)) .transpose()? .map(CompileKind::Target); - let forced_kind = resolved_package + let forced_kind = normalized_package .forced_target .as_ref() .map(|t| CompileTarget::new(&*t)) .transpose()? .map(CompileKind::Target); - let include = resolved_package - .resolved_include() - .expect("previously resolved") + let include = normalized_package + .normalized_include() + .expect("previously normalized") .cloned() .unwrap_or_default(); - let exclude = resolved_package - .resolved_exclude() - .expect("previously resolved") + let exclude = normalized_package + .normalized_exclude() + .expect("previously normalized") .cloned() .unwrap_or_default(); - let links = resolved_package.links.clone(); - let custom_metadata = resolved_package.metadata.clone(); - let im_a_teapot = resolved_package.im_a_teapot; - let default_run = resolved_package.default_run.clone(); - let metabuild = resolved_package.metabuild.clone().map(|sov| sov.0); + let links = normalized_package.links.clone(); + let custom_metadata = normalized_package.metadata.clone(); + let im_a_teapot = normalized_package.im_a_teapot; + let default_run = normalized_package.default_run.clone(); + let metabuild = normalized_package.metabuild.clone().map(|sov| sov.0); let manifest = Manifest::new( Rc::new(contents), Rc::new(document), Rc::new(original_toml), - Rc::new(resolved_toml), + Rc::new(normalized_toml), summary, default_kind, forced_kind, @@ -1565,13 +1571,13 @@ fn to_real_manifest( embedded, ); if manifest - .resolved_toml() + .normalized_toml() .package() .unwrap() .license_file .is_some() && manifest - .resolved_toml() + .normalized_toml() .package() .unwrap() .license @@ -1677,7 +1683,7 @@ fn to_virtual_manifest( contents: String, document: toml_edit::ImDocument, original_toml: manifest::TomlManifest, - resolved_toml: manifest::TomlManifest, + normalized_toml: manifest::TomlManifest, features: Features, workspace_config: WorkspaceConfig, source_id: SourceId, @@ -1719,7 +1725,7 @@ fn to_virtual_manifest( Rc::new(contents), Rc::new(document), Rc::new(original_toml), - Rc::new(resolved_toml), + Rc::new(normalized_toml), replace, patch, workspace_config, @@ -1770,15 +1776,15 @@ struct ManifestContext<'a, 'b> { #[tracing::instrument(skip_all)] fn gather_dependencies( manifest_ctx: &mut ManifestContext<'_, '_>, - resolved_deps: Option<&BTreeMap>, + normalized_deps: Option<&BTreeMap>, kind: Option, ) -> CargoResult<()> { - let Some(dependencies) = resolved_deps else { + let Some(dependencies) = normalized_deps else { return Ok(()); }; for (n, v) in dependencies.iter() { - let resolved = v.resolved().expect("previously resolved"); + let resolved = v.normalized().expect("previously normalized"); let dep = dep_to_dependency(&resolved, n, manifest_ctx, kind)?; manifest_ctx.deps.push(dep); } @@ -2559,9 +2565,13 @@ pub fn prepare_for_publish( ) -> CargoResult { let contents = me.manifest().contents(); let document = me.manifest().document(); - let original_toml = - prepare_toml_for_publish(me.manifest().resolved_toml(), ws, me.root(), packaged_files)?; - let resolved_toml = original_toml.clone(); + let original_toml = prepare_toml_for_publish( + me.manifest().normalized_toml(), + ws, + me.root(), + packaged_files, + )?; + let normalized_toml = original_toml.clone(); let features = me.manifest().unstable_features().clone(); let workspace_config = me.manifest().workspace_config().clone(); let source_id = me.package_id().source_id(); @@ -2572,7 +2582,7 @@ pub fn prepare_for_publish( contents.to_owned(), document.clone(), original_toml, - resolved_toml, + normalized_toml, features, workspace_config, source_id, @@ -2911,11 +2921,11 @@ fn prepare_target_for_publish( context: &str, gctx: &GlobalContext, ) -> CargoResult> { - let path = target.path.as_ref().expect("previously resolved"); + let path = target.path.as_ref().expect("previously normalized"); let path = normalize_path(&path.0); if let Some(packaged_files) = packaged_files { if !packaged_files.contains(&path) { - let name = target.name.as_ref().expect("previously resolved"); + let name = target.name.as_ref().expect("previously normalized"); gctx.shell().warn(format!( "ignoring {context} `{name}` as `{}` is not included in the published package", path.display() diff --git a/src/cargo/util/toml/targets.rs b/src/cargo/util/toml/targets.rs index 5827727b9c4..5de630501da 100644 --- a/src/cargo/util/toml/targets.rs +++ b/src/cargo/util/toml/targets.rs @@ -35,7 +35,7 @@ const DEFAULT_EXAMPLE_DIR_NAME: &'static str = "examples"; pub(super) fn to_targets( features: &Features, original_toml: &TomlManifest, - resolved_toml: &TomlManifest, + normalized_toml: &TomlManifest, package_root: &Path, edition: Edition, metabuild: &Option, @@ -45,7 +45,7 @@ pub(super) fn to_targets( if let Some(target) = to_lib_target( original_toml.lib.as_ref(), - resolved_toml.lib.as_ref(), + normalized_toml.lib.as_ref(), package_root, edition, warnings, @@ -53,38 +53,38 @@ pub(super) fn to_targets( targets.push(target); } - let package = resolved_toml + let package = normalized_toml .package .as_ref() .ok_or_else(|| anyhow::format_err!("manifest has no `package` (or `project`)"))?; targets.extend(to_bin_targets( features, - resolved_toml.bin.as_deref().unwrap_or_default(), + normalized_toml.bin.as_deref().unwrap_or_default(), package_root, edition, )?); targets.extend(to_example_targets( - resolved_toml.example.as_deref().unwrap_or_default(), + normalized_toml.example.as_deref().unwrap_or_default(), package_root, edition, )?); targets.extend(to_test_targets( - resolved_toml.test.as_deref().unwrap_or_default(), + normalized_toml.test.as_deref().unwrap_or_default(), package_root, edition, )?); targets.extend(to_bench_targets( - resolved_toml.bench.as_deref().unwrap_or_default(), + normalized_toml.bench.as_deref().unwrap_or_default(), package_root, edition, )?); // processing the custom build script - if let Some(custom_build) = package.resolved_build().expect("should be resolved") { + if let Some(custom_build) = package.normalized_build().expect("previously normalized") { if metabuild.is_some() { anyhow::bail!("cannot specify both `metabuild` and `build`"); } @@ -104,7 +104,7 @@ pub(super) fn to_targets( } if let Some(metabuild) = metabuild { // Verify names match available build deps. - let bdeps = resolved_toml.build_dependencies.as_ref(); + let bdeps = normalized_toml.build_dependencies.as_ref(); for name in &metabuild.0 { if !bdeps.map_or(false, |bd| bd.contains_key(name.as_str())) { anyhow::bail!( @@ -124,7 +124,7 @@ pub(super) fn to_targets( } #[tracing::instrument(skip_all)] -pub fn resolve_lib( +pub fn normalize_lib( original_lib: Option<&TomlLibTarget>, package_root: &Path, package_name: &str, @@ -176,16 +176,16 @@ pub fn resolve_lib( #[tracing::instrument(skip_all)] fn to_lib_target( original_lib: Option<&TomlLibTarget>, - resolved_lib: Option<&TomlLibTarget>, + normalized_lib: Option<&TomlLibTarget>, package_root: &Path, edition: Edition, warnings: &mut Vec, ) -> CargoResult> { - let Some(lib) = resolved_lib else { + let Some(lib) = normalized_lib else { return Ok(None); }; - let path = lib.path.as_ref().expect("previously resolved"); + let path = lib.path.as_ref().expect("previously normalized"); let path = package_root.join(&path.0); // Per the Macros 1.1 RFC: @@ -229,7 +229,7 @@ fn to_lib_target( } #[tracing::instrument(skip_all)] -pub fn resolve_bins( +pub fn normalize_bins( toml_bins: Option<&Vec>, package_root: &Path, package_name: &str, @@ -239,7 +239,7 @@ pub fn resolve_bins( errors: &mut Vec, has_lib: bool, ) -> CargoResult> { - if is_resolved(toml_bins, autodiscover) { + if is_normalized(toml_bins, autodiscover) { let toml_bins = toml_bins.cloned().unwrap_or_default(); for bin in &toml_bins { validate_bin_name(bin, warnings)?; @@ -315,7 +315,7 @@ fn to_bin_targets( let mut result = Vec::new(); for bin in bins { - let path = package_root.join(&bin.path.as_ref().expect("previously resolved").0); + let path = package_root.join(&bin.path.as_ref().expect("previously normalized").0); let mut target = Target::bin_target( name_or_panic(bin), bin.filename.clone(), @@ -352,7 +352,7 @@ fn legacy_bin_path(package_root: &Path, name: &str, has_lib: bool) -> Option>, package_root: &Path, edition: Edition, @@ -362,7 +362,7 @@ pub fn resolve_examples( ) -> CargoResult> { let mut inferred = || infer_from_directory(&package_root, Path::new(DEFAULT_EXAMPLE_DIR_NAME)); - let targets = resolve_targets( + let targets = normalize_targets( "example", "example", toml_examples, @@ -388,7 +388,7 @@ fn to_example_targets( let mut result = Vec::new(); for toml in targets { - let path = package_root.join(&toml.path.as_ref().expect("previously resolved").0); + let path = package_root.join(&toml.path.as_ref().expect("previously normalized").0); let crate_types = match toml.crate_types() { Some(kinds) => kinds.iter().map(|s| s.into()).collect(), None => Vec::new(), @@ -409,7 +409,7 @@ fn to_example_targets( } #[tracing::instrument(skip_all)] -pub fn resolve_tests( +pub fn normalize_tests( toml_tests: Option<&Vec>, package_root: &Path, edition: Edition, @@ -419,7 +419,7 @@ pub fn resolve_tests( ) -> CargoResult> { let mut inferred = || infer_from_directory(&package_root, Path::new(DEFAULT_TEST_DIR_NAME)); - let targets = resolve_targets( + let targets = normalize_targets( "test", "test", toml_tests, @@ -445,7 +445,7 @@ fn to_test_targets( let mut result = Vec::new(); for toml in targets { - let path = package_root.join(&toml.path.as_ref().expect("previously resolved").0); + let path = package_root.join(&toml.path.as_ref().expect("previously normalized").0); let mut target = Target::test_target( name_or_panic(&toml), path, @@ -459,7 +459,7 @@ fn to_test_targets( } #[tracing::instrument(skip_all)] -pub fn resolve_benches( +pub fn normalize_benches( toml_benches: Option<&Vec>, package_root: &Path, edition: Edition, @@ -484,7 +484,7 @@ pub fn resolve_benches( let mut inferred = || infer_from_directory(&package_root, Path::new(DEFAULT_BENCH_DIR_NAME)); - let targets = resolve_targets_with_legacy_path( + let targets = normalize_targets_with_legacy_path( "benchmark", "bench", toml_benches, @@ -512,7 +512,7 @@ fn to_bench_targets( let mut result = Vec::new(); for toml in targets { - let path = package_root.join(&toml.path.as_ref().expect("previously resolved").0); + let path = package_root.join(&toml.path.as_ref().expect("previously normalized").0); let mut target = Target::bench_target( name_or_panic(&toml), path, @@ -526,7 +526,7 @@ fn to_bench_targets( Ok(result) } -fn is_resolved(toml_targets: Option<&Vec>, autodiscover: Option) -> bool { +fn is_normalized(toml_targets: Option<&Vec>, autodiscover: Option) -> bool { if autodiscover != Some(false) { return false; } @@ -539,7 +539,7 @@ fn is_resolved(toml_targets: Option<&Vec>, autodiscover: Option>, @@ -551,7 +551,7 @@ fn resolve_targets( errors: &mut Vec, autodiscover_flag_name: &str, ) -> CargoResult> { - resolve_targets_with_legacy_path( + normalize_targets_with_legacy_path( target_kind_human, target_kind, toml_targets, @@ -566,7 +566,7 @@ fn resolve_targets( ) } -fn resolve_targets_with_legacy_path( +fn normalize_targets_with_legacy_path( target_kind_human: &str, target_kind: &str, toml_targets: Option<&Vec>, @@ -579,7 +579,7 @@ fn resolve_targets_with_legacy_path( legacy_path: &mut dyn FnMut(&TomlTarget) -> Option, autodiscover_flag_name: &str, ) -> CargoResult> { - if is_resolved(toml_targets, autodiscover) { + if is_normalized(toml_targets, autodiscover) { let toml_targets = toml_targets.cloned().unwrap_or_default(); for target in &toml_targets { // Check early to improve error messages @@ -1000,7 +1000,7 @@ Cargo doesn't know which to use because multiple target files found at `{}` and /// Returns the path to the build script if one exists for this crate. #[tracing::instrument(skip_all)] -pub fn resolve_build(build: Option<&StringOrBool>, package_root: &Path) -> Option { +pub fn normalize_build(build: Option<&StringOrBool>, package_root: &Path) -> Option { const BUILD_RS: &str = "build.rs"; match build { None => {