mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
refactor(toml): Pull bin proc-macro validation out
This commit is contained in:
parent
f71515698e
commit
330d5ea93a
@ -321,15 +321,7 @@ fn to_bin_targets(
|
||||
}
|
||||
|
||||
validate_bin_crate_types(bin, warnings, errors)?;
|
||||
|
||||
if bin.proc_macro() == Some(true) {
|
||||
let name = name_or_panic(bin);
|
||||
errors.push(format!(
|
||||
"the target `{}` is a binary and can't have `proc-macro` \
|
||||
set `true`",
|
||||
name
|
||||
));
|
||||
}
|
||||
validate_bin_proc_macro(bin, warnings, errors)?;
|
||||
}
|
||||
|
||||
validate_unique_names(&bins, "binary")?;
|
||||
@ -1068,6 +1060,22 @@ fn name_or_panic(target: &TomlTarget) -> &str {
|
||||
.unwrap_or_else(|| panic!("target name is required"))
|
||||
}
|
||||
|
||||
fn validate_bin_proc_macro(
|
||||
target: &TomlTarget,
|
||||
_warnings: &mut Vec<String>,
|
||||
errors: &mut Vec<String>,
|
||||
) -> CargoResult<()> {
|
||||
if target.proc_macro() == Some(true) {
|
||||
let name = name_or_panic(target);
|
||||
errors.push(format!(
|
||||
"the target `{}` is a binary and can't have `proc-macro` \
|
||||
set `true`",
|
||||
name
|
||||
));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn validate_proc_macro(
|
||||
target: &TomlTarget,
|
||||
kind: &str,
|
||||
|
Loading…
x
Reference in New Issue
Block a user