rust-lang/rust-clippy · error

the MSRV in `clippy.toml` and `Cargo.toml` differ; using

Error message

the MSRV in `clippy.toml` and `Cargo.toml` differ; using `{clippy_msrv}` from `clippy.toml`

What it means

Emitted by load_inner when the msrv set in clippy.toml differs from the rust-version (CARGO_PKG_RUST_VERSION) declared in Cargo.toml. Clippy resolves the conflict deterministically in favor of the clippy.toml value, so lints are gated on {clippy_msrv} while cargo and rustc build against the Cargo.toml MSRV. The mismatch typically means the two files were updated independently and can cause lints to fire (or not fire) against code that actually targets a different Rust version.

Solutions

  1. Set msrv in clippy.toml to the same value as rust-version in Cargo.toml
  2. Or remove msrv from clippy.toml so Clippy falls back to the Cargo.toml rust-version
  3. Automate syncing the two values in CI (e.g. a check comparing clippy.toml msrv with Cargo.toml rust-version)
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at clippy_config/src/conf.rs:965 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of rust-lang/rust-clippy@13aece1138 (2026-09-07). Data as JSON: /api/errors/b31d211c1ba795fc. Report an issue: GitHub.

Appendix: source

Thrown at clippy_config/src/conf.rs:965

                        dcx.inner
                            .struct_err(format!("error parsing `clippy.toml`: {}", e.message()))
                            .emit();
                    },
                }
            }
            Conf::deserialize(&dcx, toml.get_ref())
        } else {
            Conf::default()
        };

        let cargo_msrv = env::var("CARGO_PKG_RUST_VERSION")
            .ok()
            .and_then(|v| parse_version(Symbol::intern(&v)));
        match (&conf.msrv, cargo_msrv) {
            (None, Some(cargo_msrv)) => conf.msrv = Some(cargo_msrv),
            (Some(clippy_msrv), Some(cargo_msrv)) => {
                if *clippy_msrv != cargo_msrv {
                    sess.dcx().warn(format!(
                        "the MSRV in `clippy.toml` and `Cargo.toml` differ; using `{clippy_msrv}` from `clippy.toml`"
                    ));
                }
            },
            (_, None) => {},
        }

        conf
    }
}

#[cfg(test)]
mod tests {
    use rustc_data_structures::fx::FxHashSet;
    use std::fs;
    use toml::de::DeTable;
    use walkdir::WalkDir;

View on GitHub (pinned to 13aece1138)