Skip to content

Commit

Permalink
refactor(toml): Consistently document motivation for validation order
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed May 2, 2024
1 parent fe0819e commit cdae596
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/cargo/util/toml/targets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ pub fn resolve_lib(
let Some(mut lib) = lib else { return Ok(None) };
lib.name
.get_or_insert_with(|| package_name.replace("-", "_"));

// Check early to improve error messages
validate_lib_name(&lib, warnings)?;

// Checking the original lib
validate_proc_macro(&lib, "library", edition, warnings)?;
validate_crate_types(&lib, "library", edition, warnings)?;

Expand Down Expand Up @@ -276,7 +276,9 @@ pub fn resolve_bins(
);

for bin in &mut bins {
// Check early to improve error messages
validate_bin_name(bin, warnings)?;

validate_bin_crate_types(bin, edition, warnings, errors)?;
validate_bin_proc_macro(bin, edition, warnings, errors)?;

Expand Down Expand Up @@ -587,7 +589,9 @@ fn resolve_targets_with_legacy_path(
);

for target in &toml_targets {
// Check early to improve error messages
validate_target_name(target, target_kind_human, target_kind, warnings)?;

validate_proc_macro(target, target_kind_human, edition, warnings)?;
validate_crate_types(target, target_kind_human, edition, warnings)?;
}
Expand Down

0 comments on commit cdae596

Please sign in to comment.