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

-Zfix-edition expected a value

Error message

-Zfix-edition expected a value

What it means

Thrown while parsing unstable feature flags in src/workspace/features.rs:1447. The `-Z fix-edition` flag is a value-taking feature (it needs a target edition like `2024`), parsed via `parse_empty`-style logic that calls `v.ok_or_else(...)`. Supplying the flag without a value yields `None`, so cargo bails.

Source

Thrown at src/workspace/features.rs:1447

            "advanced-env" => self.advanced_env = parse_empty(k, v)?,
            "any-build-script-metadata" => self.any_build_script_metadata = parse_empty(k, v)?,
            "asymmetric-token" => self.asymmetric_token = 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-dir-new-layout" => self.build_dir_new_layout = parse_empty(k, v)?,
            "build-std" => self.build_std = Some(parse_list(v)),
            "build-std-features" => self.build_std_features = Some(parse_list(v)),
            "cargo-lints" => self.cargo_lints = parse_empty(k, 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)?,
            "min-publish-age" => self.min_publish_age = parse_empty(k, v)?,
            "hint-msrv" => self.hint_msrv = parse_empty(k, v)?,

View on GitHub (pinned to 0e07a15537)

Solutions

  1. Provide the edition value: `cargo +nightly fix -Z fix-edition=2024`.
  2. In config, write `[unstable] fix-edition = "2024"`.
  3. Check `cargo +nightly -Z help` for the exact value syntax of each unstable flag.

Example fix

# before
cargo +nightly fix -Z fix-edition
# after
cargo +nightly fix -Z fix-edition=2024
Defensive patterns

Strategy: validation

Validate before calling

// ensure value-taking unstable flags always carry a value
fn check_fix_edition(cfg: &str) -> Result<(), String> {
    if cfg.split_whitespace().any(|t| t == "-Z" || t == "-Zfix-edition") {
        return Err("-Z fix-edition needs =<edition>".into());
    }
    Ok(())
}

Prevention

When it happens

Trigger: Invoking `cargo +nightly fix -Z fix-edition` (no `=<edition>` and no following value), or setting `unstable.fix-edition` in `.cargo/config.toml` with no value. The match arm `"fix-edition" => { let fe = v.ok_or_else(...)? }`.

Common situations: Confusing `fix-edition` with value-less flags like `-Z bindeps`; typoing the value; nightly-only workflows copied incompletely.

Related errors


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