Skip to content

Commit 640d41d

Browse files
committed
refactor(toml): Validate bin in resolve, like other targets
1 parent 330d5ea commit 640d41d

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

src/cargo/util/toml/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ fn resolve_toml(
333333
edition,
334334
original_package.autobins,
335335
warnings,
336+
errors,
336337
resolved_toml.lib.is_some(),
337338
)?);
338339
resolved_toml.example = Some(targets::resolve_examples(
@@ -1070,7 +1071,7 @@ fn to_real_manifest(
10701071
manifest_file: &Path,
10711072
gctx: &GlobalContext,
10721073
warnings: &mut Vec<String>,
1073-
errors: &mut Vec<String>,
1074+
_errors: &mut Vec<String>,
10741075
) -> CargoResult<Manifest> {
10751076
let embedded = is_embedded(manifest_file);
10761077
let package_root = manifest_file.parent().unwrap();
@@ -1212,7 +1213,6 @@ fn to_real_manifest(
12121213
edition,
12131214
&resolved_package.metabuild,
12141215
warnings,
1215-
errors,
12161216
)?;
12171217

12181218
if targets.iter().all(|t| t.is_custom_build()) {

src/cargo/util/toml/targets.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ pub(super) fn to_targets(
4040
edition: Edition,
4141
metabuild: &Option<StringOrVec>,
4242
warnings: &mut Vec<String>,
43-
errors: &mut Vec<String>,
4443
) -> CargoResult<Vec<Target>> {
4544
let mut targets = Vec::new();
4645

@@ -64,8 +63,6 @@ pub(super) fn to_targets(
6463
resolved_toml.bin.as_deref().unwrap_or_default(),
6564
package_root,
6665
edition,
67-
warnings,
68-
errors,
6966
)?);
7067

7168
targets.extend(to_example_targets(
@@ -261,6 +258,7 @@ pub fn resolve_bins(
261258
edition: Edition,
262259
autodiscover: Option<bool>,
263260
warnings: &mut Vec<String>,
261+
errors: &mut Vec<String>,
264262
has_lib: bool,
265263
) -> CargoResult<Vec<TomlBinTarget>> {
266264
let inferred = inferred_bins(package_root, package_name);
@@ -279,6 +277,8 @@ pub fn resolve_bins(
279277

280278
for bin in &mut bins {
281279
validate_bin_name(bin, warnings)?;
280+
validate_bin_crate_types(bin, warnings, errors)?;
281+
validate_bin_proc_macro(bin, warnings, errors)?;
282282

283283
let path = target_path(bin, &inferred, "bin", package_root, edition, &mut |_| {
284284
if let Some(legacy_path) = legacy_bin_path(package_root, name_or_panic(bin), has_lib) {
@@ -309,8 +309,6 @@ fn to_bin_targets(
309309
bins: &[TomlBinTarget],
310310
package_root: &Path,
311311
edition: Edition,
312-
warnings: &mut Vec<String>,
313-
errors: &mut Vec<String>,
314312
) -> CargoResult<Vec<Target>> {
315313
// This loop performs basic checks on each of the TomlTarget in `bins`.
316314
for bin in bins {
@@ -319,9 +317,6 @@ fn to_bin_targets(
319317
if bin.filename.is_some() {
320318
features.require(Feature::different_binary_name())?;
321319
}
322-
323-
validate_bin_crate_types(bin, warnings, errors)?;
324-
validate_bin_proc_macro(bin, warnings, errors)?;
325320
}
326321

327322
validate_unique_names(&bins, "binary")?;

0 commit comments

Comments
 (0)