{"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":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/workspace/parser/mod.rs","lineNumber":1165,"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":1147,"sourceCodeEnd":1183,"githubUrl":"https://github.com/rust-lang/cargo/blob/0e07a155371a6ce88ae53a2c00df940280c09a67/src/workspace/parser/mod.rs#L1147-L1183","documentation":"Thrown by `lints_inherit_with` at src/workspace/parser/mod.rs:1165. When `[lints] workspace = true` (inherit lints from `workspace.lints`) but the same `[lints]` table also defines local lint entries, cargo refuses to merge them silently — you must either inherit fully or specify lints manually. The guard is `lints.workspace && !lints.lints.is_empty()`.","triggerScenarios":"A member manifest with `[lints]\\nworkspace = true\\n[lints.rust]\\nunsafe_code = \"warn\"` — both inheritance and a local override present.","commonSituations":"Enabling workspace lint inheritance then adding a one-off lint; merging configs during a refactor; copying a member manifest and leaving stale entries.","solutions":["Remove the local `[lints.<tool>]` entries so only `workspace = true` remains.","Or drop `workspace = true` and manually specify every lint in the member."],"exampleFix":"# before\n[lints]\nworkspace = true\n[lints.rust]\nunsafe_code = \"warn\"\n# after (inherit fully)\n[lints]\nworkspace = true\n# (move unsafe_code to [workspace.lints.rust] in the root)","handlingStrategy":"validation","validationCode":"if let Some(lints) = doc.get(\"lints\").and_then(|i| i.as_table_like()) {\n    let inherits = lints.get(\"workspace\").and_then(|v| v.as_bool()) == Some(true);\n    let has_local = lints.iter().any(|(k, _)| k != \"workspace\");\n    if inherits && has_local {\n        return Err(\"cannot mix [lints] workspace=true with local lints\".into());\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Decide upfront: inherit all lints or specify all lints locally — not both.","Run `cargo check` after editing the `[lints]` table."],"tags":["manifest","lints","workspace"],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}