{"id":"d92802afa51a5484","repo":"rust-lang/cargo","slug":"target-names-cannot-be-empty","errorCode":null,"errorMessage":"{} target names cannot be empty","messagePattern":"(.+?) target names cannot be empty","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/workspace/parser/targets.rs","lineNumber":1180,"sourceCode":"        anyhow::bail!(\n            \"the binary target name `{name}` is forbidden, \\\n                 it conflicts with cargo's build directory names\",\n        )\n    }\n\n    Ok(())\n}\n\nfn validate_target_name(\n    target: &TomlTarget,\n    target_kind_human: &str,\n    target_kind: &str,\n    warnings: &mut Vec<String>,\n) -> CargoResult<()> {\n    match target.name {\n        Some(ref name) => {\n            if name.trim().is_empty() {\n                anyhow::bail!(\"{} target names cannot be empty\", target_kind_human)\n            }\n            if cfg!(windows) && restricted_names::is_windows_reserved(name) {\n                warnings.push(format!(\n                    \"{} target `{}` is a reserved Windows filename, \\\n                        this target will not work on Windows platforms\",\n                    target_kind_human, name\n                ));\n            }\n        }\n        None => anyhow::bail!(\n            \"{} target {}.name is required\",\n            target_kind_human,\n            target_kind\n        ),\n    }\n\n    Ok(())\n}","sourceCodeStart":1162,"sourceCodeEnd":1198,"githubUrl":"https://github.com/rust-lang/cargo/blob/0e07a155371a6ce88ae53a2c00df940280c09a67/src/workspace/parser/targets.rs#L1162-L1198","documentation":"Error \"{} target names cannot be empty\" thrown in rust-lang/cargo.","triggerScenarios":"Thrown at src/workspace/parser/targets.rs:1180 when the library encounters an invalid state.","commonSituations":"Occurs when a target of the given kind has an empty `name` string in the manifest. Provide a non-empty target name.","solutions":["Provide a non-empty `name` for the target in Cargo.toml.","Remove the empty target definition if it is not needed."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}