{"id":"b6e45d01d091e580","repo":"rust-lang/cargo","slug":"multiple-slashes-in-feature-feature-is-not-all","errorCode":null,"errorMessage":"multiple slashes in feature `{feature}` is not allowed","messagePattern":"multiple slashes in feature `(.+?)` is not allowed","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/bin/cargo/commands/add.rs","lineNumber":328,"sourceCode":"                    .1\n                    .get_or_insert_with(IndexSet::default)\n                    .insert(feature.to_owned());\n            }\n            FeatureValue::Dep { .. } => {\n                anyhow::bail!(\"feature `{feature}` is not allowed to use explicit `dep:` syntax\",)\n            }\n            FeatureValue::DepFeature {\n                dep_name,\n                dep_feature,\n                ..\n            } => {\n                if infer_crate_name {\n                    anyhow::bail!(\n                        \"`{feature}` is unsupported when inferring the crate name, use `{dep_feature}`\"\n                    );\n                }\n                if dep_feature.contains('/') {\n                    anyhow::bail!(\"multiple slashes in feature `{feature}` is not allowed\");\n                }\n                crates.get_mut(&Some(dep_name.as_str().to_owned())).ok_or_else(|| {\n                    anyhow::format_err!(\"feature `{dep_feature}` activated for crate `{dep_name}` but the crate wasn't specified\")\n                })?\n                    .get_or_insert_with(IndexSet::default)\n                    .insert(dep_feature.as_str().to_owned());\n            }\n        }\n    }\n\n    let mut deps: Vec<DepOp> = Vec::new();\n    for (crate_spec, features) in crates {\n        let dep = DepOp {\n            crate_spec,\n            rename: rename.map(String::from),\n            features,\n            default_features,\n            optional,","sourceCodeStart":310,"sourceCodeEnd":346,"githubUrl":"https://github.com/rust-lang/cargo/blob/0e07a155371a6ce88ae53a2c00df940280c09a67/src/bin/cargo/commands/add.rs#L310-L346","documentation":"From parse_dependencies (src/bin/cargo/commands/add.rs:327-329). In the DepFeature branch it checks if dep_feature (the part after the slash) itself contains a `/`. Only one slash (dep/feature) is allowed; a second slash means a malformed nested feature spec, which Cargo rejects.","triggerScenarios":"`cargo add tokio --features tokio/rt/macros` or any --features token that, after the first split, still contains a slash.","commonSituations":"Trying to chain features across nested dependencies through one token; copying a path-like string into --features; misunderstanding that only `dep/feature` (one level) is supported.","solutions":["List each feature separately with its own dep/feature: `--features tokio/rt,tokio/macros`.","Activate additional features of the dependency directly under that dependency in Cargo.toml.","Verify there is exactly one `/` per feature token."],"exampleFix":"// before\ncargo add tokio --features tokio/rt/macros\n\n// after\ncargo add tokio --features tokio/rt,tokio/macros","handlingStrategy":"validation","validationCode":"// Reject feature tokens with more than one slash before invoking cargo add\nfn valid_feature_token(f: &str) -> bool {\n    f.matches('/').count() <= 1\n}\n\nif !features.iter().all(|f| valid_feature_token(f)) {\n    eprintln!(\"each --features value may have at most one `/`\");\n}","typeGuard":"fn has_at_most_one_slash(s: &str) -> bool {\n    s.matches('/').count() <= 1\n}","tryCatchPattern":null,"preventionTips":["Use exactly one slash per feature: `dep/feature`.","List multiple features as comma-separated tokens, not nested slashes."],"tags":["cargo","add","features","cli"],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}