{"record":{"id":"1b0a3089e711294a","repo":"rust-lang/cargo","slug":"cannot-override-workspace-lints-in-lints-eith","errorCode":null,"errorMessage":"cannot override `workspace.lints` in `lints`, either remove the overrides or `lints.workspace = true` and manually specify the lints","messagePattern":"cannot override `workspace\\.lints` in `lints`, either remove the overrides or `lints\\.workspace = true` and manually specify the lints","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/workspace/parser/mod.rs","lineNumber":1164,"sourceCode":"    get_ws_inheritable: impl FnOnce() -> CargoResult<T>,\n) -> CargoResult<T> {\n    match field {\n        manifest::InheritableField::Value(value) => Ok(value),\n        manifest::InheritableField::Inherit(_) => get_ws_inheritable().with_context(|| {\n            format!(\n                \"error inheriting `{label}` from workspace root manifest's `workspace.package.{label}`\",\n            )\n        }),\n    }\n}\n\nfn lints_inherit_with(\n    lints: manifest::InheritableLints,\n    get_ws_inheritable: impl FnOnce() -> CargoResult<manifest::TomlLints>,\n) -> CargoResult<manifest::TomlLints> {\n    if lints.workspace {\n        if !lints.lints.is_empty() {\n            anyhow::bail!(\n                \"cannot override `workspace.lints` in `lints`, either remove the overrides or `lints.workspace = true` and manually specify the lints\"\n            );\n        }\n        get_ws_inheritable().with_context(\n            || \"error inheriting `lints` from workspace root manifest's `workspace.lints`\",\n        )\n    } else {\n        Ok(lints.lints)\n    }\n}\n\nfn dependency_inherit_with<'a>(\n    dependency: manifest::InheritableDependency,\n    name: &str,\n    inherit: &dyn Fn() -> CargoResult<&'a InheritableFields>,\n    package_root: &Path,\n    edition: Edition,\n    warnings: &mut Vec<String>,","sourceCodeStart":1146,"sourceCodeEnd":1182,"githubUrl":"https://github.com/rust-lang/cargo/blob/98a09e7e7d62850f14e5b6132101fc1edd19a16f/src/workspace/parser/mod.rs#L1146-L1182","documentation":"Thrown by lints_inherit_with when the [lints] table sets workspace = true AND simultaneously defines specific lints. Cargo treats these as mutually exclusive: either inherit all lints from the workspace or specify them locally. Mixing produces ambiguous precedence, so the parser rejects it outright with guidance to choose one strategy.","triggerScenarios":"A manifest contains [lints] with both 'workspace = true' and one or more lint entries, e.g. [lints.workspace] = true alongside [lints.rust] dead_code = 'warn'. lints.workspace is true and lints.lints is non-empty.","commonSituations":"A developer starts with workspace lints then tries to override a single lint locally. A merge tool combines two manifest edits, one adding workspace=true and another adding a lint. Copy-pasting a lint config into a workspace-inheriting package.","solutions":["Remove the local lint entries and rely solely on the workspace's [workspace.lints] definition.","Or set lints.workspace = false (or remove it) and manually specify every lint you need locally.","To customize, edit the workspace root's [workspace.lints] so all members inherit the change."],"exampleFix":"# before\n[lints]\nworkspace = true\n\n[lints.rust]\nunsafe_code = \"forbid\"  # conflicts with workspace inheritance\n\n# after (option A: inherit only)\n[lints]\nworkspace = true\n\n# after (option B: local only)\n[lints.rust]\nunsafe_code = \"forbid\"","handlingStrategy":"validation","validationCode":"fn lints_inherit_is_consistent(toml: &str) -> Result<(), String> {\n    let v: toml::Value = toml::from_str(toml).map_err(|e| e.to_string())?;\n    if let Some(lints) = v.get(\"lints\").and_then(|l| l.as_table()) {\n        let workspace_true = lints.get(\"workspace\").and_then(|w| w.as_bool()) == Some(true);\n        let has_local = lints.keys().any(|k| k != \"workspace\");\n        if workspace_true && has_local {\n            return Err(\"cannot set lints.workspace = true and define local lints\".into());\n        }\n    }\n    Ok(())\n}","typeGuard":"fn lints_config_is_valid(lints: &toml::value::Table) -> bool {\n    let ws = lints.get(\"workspace\").and_then(|w| w.as_bool()) == Some(true);\n    let local = lints.keys().any(|k| k != \"workspace\");\n    !(ws && local)\n}","tryCatchPattern":null,"preventionTips":["Choose one lints strategy: workspace inheritance OR local specification, not both.","Edit [workspace.lints] in the root to change inherited lints across members.","Lint manifests in CI to catch mixed lints configurations."],"tags":["cargo","lints","workspace","inheritance","manifest"],"backgroundTag":null,"analyzedSha":"98a09e7e7d62850f14e5b6132101fc1edd19a16f","analyzedAt":"2026-08-11T17:42:36.556Z","contentChangedAt":"2026-08-11T17:42:36.556Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}