{"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":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/ops/cargo_new.rs","lineNumber":234,"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":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/rust-lang/cargo/blob/0e07a155371a6ce88ae53a2c00df940280c09a67/src/ops/cargo_new.rs#L216-L252","documentation":"check_name hard-rejects the exact name `test` because it collides with Rust's built-in test harness crate (extern crate test), which is implicitly available to every Rust program. The trailing {help} suggests a [[bin]] override. Unlike the broader std-library names (core/std/alloc) which only warn, `test` is always fatal.","triggerScenarios":"`cargo new test`, `cargo new --name test`, or running `cargo new` inside a directory literally named `test`. The name == \"test\" comparison at cargo_new.rs:233 fires.","commonSituations":"Creating a crate inside a folder called `test/` (common monorepo layout), scaffolding a crate whose purpose is testing, or following a tutorial that uses `test` as the example name.","solutions":["Choose a different name such as `tester`, `test-utils`, or `my-tests`","Use `--name <something-else>` to override the directory-derived name","Rename the parent directory from `test` to e.g. `tests` or `test-harness`"],"exampleFix":"# before\ncargo new test\n# after\ncargo new test --name my-test   # or move dir: cargo new my-test","handlingStrategy":"validation","validationCode":"fn is_reserved_std_name(name: &str) -> bool {\n    matches!(name, \"test\")\n}\n\nif is_reserved_std_name(name) { /* reject; 'test' is always invalid */ }","typeGuard":"function isNotTestName(name: string): boolean { return name !== 'test'; }","tryCatchPattern":null,"preventionTips":["Never name a crate `test`; use `tester` or `<topic>-test`","Avoid creating cargo crates inside a directory literally named `test`","Lint Cargo.toml names in CI against the reserved std set"],"tags":["cargo-new","package-name","std-library","naming"],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}