Skip to content

Commit 330d5ea

Browse files
committed
refactor(toml): Pull bin proc-macro validation out
1 parent f715156 commit 330d5ea

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

src/cargo/util/toml/targets.rs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -321,15 +321,7 @@ fn to_bin_targets(
321321
}
322322

323323
validate_bin_crate_types(bin, warnings, errors)?;
324-
325-
if bin.proc_macro() == Some(true) {
326-
let name = name_or_panic(bin);
327-
errors.push(format!(
328-
"the target `{}` is a binary and can't have `proc-macro` \
329-
set `true`",
330-
name
331-
));
332-
}
324+
validate_bin_proc_macro(bin, warnings, errors)?;
333325
}
334326

335327
validate_unique_names(&bins, "binary")?;
@@ -1068,6 +1060,22 @@ fn name_or_panic(target: &TomlTarget) -> &str {
10681060
.unwrap_or_else(|| panic!("target name is required"))
10691061
}
10701062

1063+
fn validate_bin_proc_macro(
1064+
target: &TomlTarget,
1065+
_warnings: &mut Vec<String>,
1066+
errors: &mut Vec<String>,
1067+
) -> CargoResult<()> {
1068+
if target.proc_macro() == Some(true) {
1069+
let name = name_or_panic(target);
1070+
errors.push(format!(
1071+
"the target `{}` is a binary and can't have `proc-macro` \
1072+
set `true`",
1073+
name
1074+
));
1075+
}
1076+
Ok(())
1077+
}
1078+
10711079
fn validate_proc_macro(
10721080
target: &TomlTarget,
10731081
kind: &str,

0 commit comments

Comments
 (0)