rust-lang/cargo · error · anyhow::Error

Use of `default_features` in `{key}` is unsupported, please

Error message

Use of `default_features` in `{key}` is unsupported, please switch to `default-features`

What it means

Thrown by `Dependency::from_toml` (editor) at src/workspace/editor/dependency.rs:342. Cargo's manifest format requires the hyphenated key `default-features`; the underscore variant `default_features` (leftover from early TOML/Python conventions) is explicitly rejected by the dependency editor so manifests stay canonical.

Source

Thrown at src/workspace/editor/dependency.rs:342

                        "dependency ({key}) specified without \
                        providing a local path, Git repository, version, or \
                        workspace dependency to use"
                    );
                };
            let registry = if let Some(value) = table.get("registry") {
                Some(
                    value
                        .as_str()
                        .ok_or_else(|| invalid_type(key, "registry", value.type_name(), "string"))?
                        .to_owned(),
                )
            } else {
                None
            };

            let default_features = table.get("default-features").and_then(|v| v.as_bool());
            if table.contains_key("default_features") {
                anyhow::bail!(
                    "Use of `default_features` in `{key}` is unsupported, please switch to `default-features`"
                );
            }

            let features = if let Some(value) = table.get("features") {
                Some(
                    value
                        .as_array()
                        .ok_or_else(|| invalid_type(key, "features", value.type_name(), "array"))?
                        .iter()
                        .map(|v| {
                            v.as_str().map(|s| s.to_owned()).ok_or_else(|| {
                                invalid_type(key, "features", v.type_name(), "string")
                            })
                        })
                        .collect::<CargoResult<IndexSet<String>>>()?,
                )
            } else {

View on GitHub (pinned to 0e07a15537)

Solutions

  1. Rename the key to `default-features`: `foo = { version = "1.0", default-features = false }`.
  2. Run `cargo fmt --manifest-path Cargo.toml`/a find-and-replace of `default_features` → `default-features` in all dependency tables.

Example fix

# before
foo = { version = "1.0", default_features = false }
# after
foo = { version = "1.0", default-features = false }
Defensive patterns

Strategy: validation

Validate before calling

// reject the underscore spelling in any dependency table
for (_k, item) in deps {
    if let Some(t) = item.as_table_like() {
        if t.contains_key("default_features") {
            eprintln!("use `default-features` (hyphen), not default_features");
        }
    }
}

Prevention

When it happens

Trigger: A dependency table containing `default_features = false` (underscore), e.g. `foo = { version = "1.0", default_features = false }`. The check is `table.contains_key("default_features")` and fires regardless of value.

Common situations: Copy-pasting from old blog posts or non-Rust TOML examples; auto-formatters or LLM suggestions using underscores; porting config from another ecosystem.

Related errors


AI-assisted analysis of rust-lang/cargo@0e07a15537 (2026-08-06). Data as JSON: /data/errors/f8102f8ed5870479.json. Report an issue: GitHub.