{"record":{"id":"ec7a4f32fa10892c","repo":"rust-lang/cargo","slug":"invalid-package-name-test-it-conflicts-with-rus","errorCode":null,"errorMessage":"invalid package name `test`: it conflicts with Rust's built-in test library{}","messagePattern":"invalid package name `test`: it conflicts with Rust's built-in test library(.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/ops/cargo_new.rs","lineNumber":183,"sourceCode":"    if restricted_names::is_conflicting_artifact_name(name) {\n        if has_bin {\n            anyhow::bail!(\n                \"invalid package name `{}`: \\\n                it conflicts with cargo's build directory names{}\",\n                name,\n                name_help\n            );\n        } else {\n            shell.warn(format!(\n                \"package `{}` will not support binary \\\n                executables with that name, \\\n                it conflicts with cargo's build directory names\",\n                name\n            ))?;\n        }\n    }\n    if name == \"test\" {\n        anyhow::bail!(\n            \"invalid package name `test`: \\\n            it conflicts with Rust's built-in test library{}\",\n            bin_help()\n        );\n    }\n    if [\"core\", \"std\", \"alloc\", \"proc_macro\", \"proc-macro\"].contains(&name) {\n        shell.warn(format!(\n            \"package name `{}` may be confused with the package with that name in Rust's standard library\\n\\\n            It is recommended to use a different name to avoid problems.{}\",\n            name,\n            bin_help()\n        ))?;\n    }\n    if restricted_names::is_windows_reserved(name) {\n        if cfg!(windows) {\n            anyhow::bail!(\n                \"invalid package name `{}`: it is a reserved Windows filename{}\",\n                name,","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/rust-lang/cargo/blob/98a09e7e7d62850f14e5b6132101fc1edd19a16f/src/ops/cargo_new.rs#L165-L201","documentation":"The literal name `test` is unconditionally rejected (hard error, not a warning) because it clashes with Rust's built-in `test` library that the test harness links against. This check is independent of `is_keyword` (note: `test` is not in the keyword list) and runs for every new package, bin or lib. The help again explains the `[[bin]]` workaround.","triggerScenarios":"`cargo new test`, `cargo init --name test`, `cargo new --name test anything`.","commonSituations":"Creating a crate literally to experiment with testing and naming it `test`. Scaffolding from a directory named `test`. Tutorial repos that use `test` as a placeholder name.","solutions":["Choose a different name: `test-utils`, `my-tests`, `testing-ground`, etc.","If you want a binary invoked as `test`, keep a valid package name and set `[[bin]] name = \"test\"` (though this can still confuse the test harness — prefer a distinct name)."],"exampleFix":"# before\n$ cargo new test   # error: conflicts with Rust's built-in test library\n\n# after\n$ cargo new test-utils","handlingStrategy":"validation","validationCode":"fn is_test_name(name: &str) -> bool { name == \"test\" }\n// reject the literal name \"test\" for any new package.","typeGuard":"fn is_not_test_builtin(name: &str) -> bool { name != \"test\" }","tryCatchPattern":null,"preventionTips":["Never name a package `test`; it collides with Rust's built-in test library.","Use descriptive variants (`test-utils`, `my-tests`).","In scaffolding tools, add `test` to the reject list alongside keywords."],"tags":["package-name","cargo-new","test","naming"],"backgroundTag":null,"analyzedSha":"98a09e7e7d62850f14e5b6132101fc1edd19a16f","analyzedAt":"2026-08-11T17:42:36.556Z","contentChangedAt":"2026-08-11T17:42:36.556Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}