{"id":"eb404e69db01c4eb","repo":"rust-lang/cargo","slug":"edges-public-requires-zunstable-options","errorCode":null,"errorMessage":"`--edges public` requires `-Zunstable-options`","messagePattern":"`--edges public` requires `-Zunstable-options`","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/bin/cargo/commands/tree.rs","lineNumber":307,"sourceCode":"                            true\n                        }\n                    })\n                    .collect()\n            },\n        );\n\n        if args.flag(\"no-dev-dependencies\") {\n            gctx.shell()\n                .warn(\"the --no-dev-dependencies flag has changed to -e=no-dev\")?;\n            kinds.push(\"no-dev\");\n        }\n\n        if kinds.is_empty() {\n            kinds.extend(&[\"normal\", \"build\", \"dev\"]);\n        }\n\n        if public && !gctx.cli_unstable().unstable_options {\n            anyhow::bail!(\"`--edges public` requires `-Zunstable-options`\");\n        }\n\n        (kinds, no_proc_macro, public)\n    };\n\n    let mut result = HashSet::default();\n    let insert_defaults = |result: &mut HashSet<EdgeKind>| {\n        result.insert(EdgeKind::Dep(DepKind::Normal));\n        result.insert(EdgeKind::Dep(DepKind::Build));\n        result.insert(EdgeKind::Dep(DepKind::Development));\n    };\n    if kinds.iter().any(|k| k.starts_with(\"no-\")) {\n        insert_defaults(&mut result);\n        for kind in &kinds {\n            match *kind {\n                \"no-normal\" => result.remove(&EdgeKind::Dep(DepKind::Normal)),\n                \"no-build\" => result.remove(&EdgeKind::Dep(DepKind::Build)),\n                \"no-dev\" => result.remove(&EdgeKind::Dep(DepKind::Development)),","sourceCodeStart":289,"sourceCodeEnd":325,"githubUrl":"https://github.com/rust-lang/cargo/blob/0e07a155371a6ce88ae53a2c00df940280c09a67/src/bin/cargo/commands/tree.rs#L289-L325","documentation":"`cargo tree --edges public` exposes the dependency graph's public surface, but that edge kind is gated behind `-Zunstable-options`. parse_edge_kinds (tree.rs:306-308) checks `gctx.cli_unstable().unstable_options` and bails with this message when the `public` edge was requested on stable.","triggerScenarios":"Running `cargo tree -e public` (or `--edges public`) without passing `-Zunstable-options` on a nightly toolchain.","commonSituations":"Following nightly-only documentation on stable; CI pinned to stable that uses the public-edge feature; scripts written against nightly run on stable.","solutions":["Run on nightly and pass `-Zunstable-options`, e.g. `cargo +nightly tree -Zunstable-options -e public`.","If you must stay on stable, omit `public` from `--edges`.","Pin the CI toolchain to nightly where this feature is used."],"exampleFix":"// before\n$ cargo tree -e public\nerror: `--edges public` requires `-Zunstable-options`\n\n// after\n$ cargo +nightly tree -Zunstable-options -e public","handlingStrategy":"validation","validationCode":"let needs_public = edges.iter().any(|e| e == \"public\");\nif needs_public && !nightly_with_z_unstable_options {\n    return Err(\"--edges public requires nightly + -Zunstable-options\".into());\n}","typeGuard":"fn requires_unstable(edges: &[String]) -> bool {\n    edges.iter().any(|e| e == \"public\")\n}\n","tryCatchPattern":null,"preventionTips":["Use rust-toolchain.toml to pin nightly where unstable tree edges are used.","Gate unstable flags behind a feature flag in build scripts."],"tags":["cargo","tree","unstable","nightly","argument"],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}