{"id":"993d35f9c01a3d2e","repo":"rust-lang/cargo","slug":"normalized-have-a-path","errorCode":null,"errorMessage":"normalized have a path","messagePattern":"normalized have a path","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/diagnostics/rules/non_kebab_case_bins.rs","lineNumber":220,"sourceCode":"                    ),\n                );\n            } else {\n                report.push(\n                    Level::HELP\n                        .secondary_title(help_package_name)\n                        .element(Origin::path(manifest_path)),\n                );\n                report.push(\n                    Level::HELP\n                        .secondary_title(help_bin_table)\n                        .element(Origin::path(manifest_path)),\n                );\n            }\n        } else {\n            let path = bin\n                .path\n                .as_ref()\n                .expect(\"normalized have a path\")\n                .0\n                .as_path();\n            let display_path = path.as_os_str().to_string_lossy();\n            let end = display_path.len() - if display_path.ends_with(\".rs\") { 3 } else { 0 };\n            let start = path\n                .parent()\n                .map(|p| {\n                    let p = p.as_os_str().to_string_lossy();\n                    // Account for trailing slash that was removed\n                    p.len() + if p.is_empty() { 0 } else { 1 }\n                })\n                .unwrap_or(0);\n            let help = Level::HELP\n                .secondary_title(format!(\n                    \"to change the binary name to `{kebab_case}`, convert the file stem\"\n                ))\n                .element(Snippet::source(display_path).patch(Patch::new(start..end, kebab_case)));\n            report.push(help);","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/rust-lang/cargo/blob/0e07a155371a6ce88ae53a2c00df940280c09a67/src/diagnostics/rules/non_kebab_case_bins.rs#L202-L238","documentation":"This panic is in the non-kebab-case-bin-names lint diagnostic generator. When a binary target's name is not kebab-case and the bin has been normalized (its name was inferred or set via the [package] name rather than an explicit [[bin]] table), the code reaches the else branch at line 216 and expects bin.path to be Some. The invariant is that normalization always assigns a path.","triggerScenarios":"Having a Cargo.toml where a binary target triggers the non-kebab-case lint but its path field is None after normalization — which could happen if the manifest has an inconsistent [[bin]] entry with a name but no path and no src/main.rs convention.","commonSituations":"A manifest with a [[bin]] target that has a non-kebab-case name, no explicit path, and doesn't follow the src/bin/<name>.rs or src/main.rs convention; a workspace with unusual target inheritance; a cargo version where the normalization logic has a gap.","solutions":["Add an explicit path to the [[bin]] entry: [[bin]] name = \"my_binary\" path = \"src/main.rs\".","Rename the binary target to kebab-case to avoid the lint entirely.","Ensure the binary source file follows cargo's default path conventions (src/bin/<name>.rs)."],"exampleFix":"# before\n[[bin]]\nname = \"MyBinary\"\n# after (add explicit path)\n[[bin]]\nname = \"MyBinary\"\npath = \"src/bin/my_binary.rs\"","handlingStrategy":"validation","validationCode":"// Before relying on the lint, ensure bin targets have explicit paths\nfor bin in manifest.bin_targets() {\n    if bin.path.is_none() {\n        eprintln!(\"warning: bin `{}` has no explicit path; add [[bin]] path = \\\"...\\\"\", bin.name);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add explicit path fields to all [[bin]] targets in Cargo.toml.","Follow cargo's default path conventions: src/main.rs or src/bin/<name>.rs.","Rename non-kebab-case binary targets to kebab-case to avoid the lint entirely."],"tags":["rust","cargo","panic","invariant","lint","manifest","bin-targets"],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}