{"record":{"id":"f8102f8ed5870479","repo":"rust-lang/cargo","slug":"use-of-default-features-in-key-is-unsupporte","errorCode":null,"errorMessage":"Use of `default_features` in `{key}` is unsupported, please switch to `default-features`","messagePattern":"Use of `default_features` in `(.+?)` is unsupported, please switch to `default-features`","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/workspace/editor/dependency.rs","lineNumber":342,"sourceCode":"                        \"dependency ({key}) specified without \\\n                        providing a local path, Git repository, version, or \\\n                        workspace dependency to use\"\n                    );\n                };\n            let registry = if let Some(value) = table.get(\"registry\") {\n                Some(\n                    value\n                        .as_str()\n                        .ok_or_else(|| invalid_type(key, \"registry\", value.type_name(), \"string\"))?\n                        .to_owned(),\n                )\n            } else {\n                None\n            };\n\n            let default_features = table.get(\"default-features\").and_then(|v| v.as_bool());\n            if table.contains_key(\"default_features\") {\n                anyhow::bail!(\n                    \"Use of `default_features` in `{key}` is unsupported, please switch to `default-features`\"\n                );\n            }\n\n            let features = if let Some(value) = table.get(\"features\") {\n                Some(\n                    value\n                        .as_array()\n                        .ok_or_else(|| invalid_type(key, \"features\", value.type_name(), \"array\"))?\n                        .iter()\n                        .map(|v| {\n                            v.as_str().map(|s| s.to_owned()).ok_or_else(|| {\n                                invalid_type(key, \"features\", v.type_name(), \"string\")\n                            })\n                        })\n                        .collect::<CargoResult<IndexSet<String>>>()?,\n                )\n            } else {","sourceCodeStart":324,"sourceCodeEnd":360,"githubUrl":"https://github.com/rust-lang/cargo/blob/eb98b54bc9f3c74519f43d066cb3fd02ebc88df0/src/workspace/editor/dependency.rs#L324-L360","documentation":"Thrown by the manifest editor dependency parser when a dependency table contains the key 'default_features' (with an underscore). Cargo's canonical field name is 'default-features' (with a hyphen); the underscore variant is not accepted by the editor. The message directs the user to rename the key. Note this is a hard rejection (bail), not a warning, because the editor cannot safely guess intent.","triggerScenarios":"Calling Dependency::from_toml on a table containing the key 'default_features'. This frequently comes from JSON-serialized manifests (JSON has no hyphens in conventional identifiers) or from copy-paste of Python/JS-style config.","commonSituations":"A developer writes default_features = false by habit from other ecosystems. A tool that round-trips Cargo.toml through JSON and back converts hyphens to underscores. Copying dependency snippets from blog posts that use the underscore form.","solutions":["Rename the key from 'default_features' to 'default-features' in the dependency table.","If a code generator produced the underscore form, fix its output template to use the hyphenated key.","Run `cargo fix --edition` or a manifest linter to normalize the field name."],"exampleFix":"# before\n[dependencies]\nserde = { version = \"1.0\", default_features = false }\n\n# after\n[dependencies]\nserde = { version = \"1.0\", default-features = false }","handlingStrategy":"validation","validationCode":"fn check_no_underscore_default_features(table: &toml_edit::Item) -> Result<(), String> {\n    if let Some(t) = table.as_table_like() {\n        if t.contains_key(\"default_features\") {\n            return Err(\"rename `default_features` to `default-features`\".into());\n        }\n    }\n    Ok(())\n}","typeGuard":"fn uses_hyphen_default_features(table: &dyn toml_edit::TableLike) -> bool {\n    !table.contains_key(\"default_features\")\n}","tryCatchPattern":null,"preventionTips":["Always use the hyphenated form `default-features` in Cargo.toml.","When round-tripping through JSON, restore hyphens before writing TOML.","Add a pre-commit hook that rejects `default_features` in Cargo.toml files."],"tags":["cargo","manifest","dependencies","naming","editor"],"backgroundTag":null,"analyzedSha":"eb98b54bc9f3c74519f43d066cb3fd02ebc88df0","analyzedAt":"2026-08-11T17:42:36.556Z","contentChangedAt":"2026-08-11T17:42:36.556Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}