rust-lang/cargo · error
-Zfix-edition expected a value
Error message
-Zfix-edition expected a value
What it means
Thrown while parsing the -Z (unstable) feature flags when the 'fix-edition' key is present but its value is None. Unlike flags parsed with parse_empty (which accept no value), fix-edition requires an explicit edition value that is then parsed via FromStr. The ok_or_else converts the Option<String> into an error when it is None.
Solutions
- Provide an edition value: -Z fix-edition=2024 (or whichever edition you are migrating to).
- Check the calling code that constructs the -Z flag list and ensure value-bearing flags include '=value'.
- Consult `cargo fix --help` and the unstable documentation for the correct syntax.
Example fix
# before cargo fix -Z fix-edition # after cargo fix -Z fix-edition=2024
Defensive patterns
Strategy: validation
Validate before calling
fn parse_fix_edition(v: Option<&str>) -> Result<Edition, String> {
let raw = v.ok_or("-Zfix-edition requires a value, e.g. -Zfix-edition=2024")?;
raw.parse().map_err(|e: _| format!("invalid edition `{raw}`: {e}"))
} Prevention
- Always pass -Z flags as key=value when the flag requires a value.
- Validate the -Z flag list before forwarding to cargo.
- Keep a reference of value-bearing unstable flags in wrapper tooling.
When it happens
Trigger: Passing -Z fix-edition with no '=VALUE' on the command line or in a config that sets the key to an empty/flag form. Internally, GitFeatures::parse or the -Z parser receives (k='fix-edition', v=None).
Common situations: A user runs `cargo fix -Z fix-edition` without appending the target edition. A script or config writes fix-edition as a boolean flag rather than a key=value pair. A wrapper tool forwards -Z flags incorrectly, dropping the value.
Related errors
- argument for --color must be auto, always, or never, but…
- argument for --color must be auto, always, or never, but…
- cannot publish with `open-namespaces`
- not implemented
- parsing ` ` requires `-Zscript
AI-assisted analysis of rust-lang/cargo@98a09e7e7d (2026-08-11).
Data as JSON: /api/errors/e1e525abfc05fe7b.
Report an issue: GitHub.
Appendix: source
Thrown at src/workspace/features.rs:1430
// Unstable features
// Sorted alphabetically:
"advanced-env" => self.advanced_env = parse_empty(k, v)?,
"any-build-script-metadata" => self.any_build_script_metadata = parse_empty(k, v)?,
"avoid-dev-deps" => self.avoid_dev_deps = parse_empty(k, v)?,
"binary-dep-depinfo" => self.binary_dep_depinfo = parse_empty(k, v)?,
"bindeps" => self.bindeps = parse_empty(k, v)?,
"build-analysis" => self.build_analysis = parse_empty(k, v)?,
"build-std" => self.build_std = Some(parse_list(v)),
"build-std-features" => self.build_std_features = Some(parse_list(v)),
"codegen-backend" => self.codegen_backend = parse_empty(k, v)?,
"direct-minimal-versions" => self.direct_minimal_versions = parse_empty(k, v)?,
"dual-proc-macros" => self.dual_proc_macros = parse_empty(k, v)?,
"feature-unification" => self.feature_unification = parse_empty(k, v)?,
"fine-grain-locking" => self.fine_grain_locking = parse_empty(k, v)?,
"fix-edition" => {
let fe = v
.ok_or_else(|| anyhow::anyhow!("-Zfix-edition expected a value"))?
.parse()?;
self.fix_edition = Some(fe);
}
"gc" => self.gc = parse_empty(k, v)?,
"git" => {
self.git =
v.map_or_else(|| Ok(Some(GitFeatures::all())), |v| parse_git(v.split(',')))?
}
"gitoxide" => {
self.gitoxide = v.map_or_else(
|| Ok(Some(GitoxideFeatures::all())),
|v| parse_gitoxide(v.split(',')),
)?
}
"host-config" => self.host_config = parse_empty(k, v)?,
"json-target-spec" => self.json_target_spec = parse_empty(k, v)?,
"hint-msrv" => self.hint_msrv = parse_empty(k, v)?,
"next-lockfile-bump" => self.next_lockfile_bump = parse_empty(k, v)?,View on GitHub (pinned to 98a09e7e7d)