rust-lang/cargo · error · anyhow::Error
{} target names cannot be empty
Error message
{} target names cannot be empty What it means
Error "{} target names cannot be empty" thrown in rust-lang/cargo.
Source
Thrown at src/workspace/parser/targets.rs:1180
anyhow::bail!(
"the binary target name `{name}` is forbidden, \
it conflicts with cargo's build directory names",
)
}
Ok(())
}
fn validate_target_name(
target: &TomlTarget,
target_kind_human: &str,
target_kind: &str,
warnings: &mut Vec<String>,
) -> CargoResult<()> {
match target.name {
Some(ref name) => {
if name.trim().is_empty() {
anyhow::bail!("{} target names cannot be empty", target_kind_human)
}
if cfg!(windows) && restricted_names::is_windows_reserved(name) {
warnings.push(format!(
"{} target `{}` is a reserved Windows filename, \
this target will not work on Windows platforms",
target_kind_human, name
));
}
}
None => anyhow::bail!(
"{} target {}.name is required",
target_kind_human,
target_kind
),
}
Ok(())
}View on GitHub (pinned to 0e07a15537)
Solutions
- Provide a non-empty `name` for the target in Cargo.toml.
- Remove the empty target definition if it is not needed.
When it happens
Trigger: Thrown at src/workspace/parser/targets.rs:1180 when the library encounters an invalid state.
Common situations: Occurs when a target of the given kind has an empty `name` string in the manifest. Provide a non-empty target name.
AI-assisted analysis of rust-lang/cargo@0e07a15537 (2026-08-06).
Data as JSON: /data/errors/d92802afa51a5484.json.
Report an issue: GitHub.