{"id":"f09ae8e64de87448","repo":"rust-lang/cargo","slug":"target-name-is-required","errorCode":null,"errorMessage":"{} target {}.name is required","messagePattern":"(.+?) target (.+?)\\.name is required","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/workspace/parser/targets.rs","lineNumber":1190,"sourceCode":"    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}\n\nfn validate_bin_proc_macro(\n    target: &TomlTarget,\n    edition: Edition,\n    warnings: &mut Vec<String>,\n    errors: &mut Vec<String>,\n) -> CargoResult<()> {\n    if target.proc_macro() == Some(true) {\n        let name = name_or_panic(target);\n        errors.push(format!(","sourceCodeStart":1172,"sourceCodeEnd":1208,"githubUrl":"https://github.com/rust-lang/cargo/blob/0e07a155371a6ce88ae53a2c00df940280c09a67/src/workspace/parser/targets.rs#L1172-L1208","documentation":"Error \"{} target {}.name is required\" thrown in rust-lang/cargo.","triggerScenarios":"Thrown at src/workspace/parser/targets.rs:1190 when the library encounters an invalid state.","commonSituations":"Occurs when a target table (e.g. `[[bin]]`, `[[test]]`) omits the required `name` key. Add `name = \"...\"` to the target definition.","solutions":["Add a `name` field to the target definition in Cargo.toml."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}