{"record":{"id":"31b33ab44f7e05a0","repo":"rust-lang/cargo","slug":"warnings-are-denied-by-build-warnings-configurat-31b33a","errorCode":null,"errorMessage":"warnings are denied by `build.warnings` configuration","messagePattern":"warnings are denied by `build\\.warnings` configuration","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/ops/cargo_fetch.rs","lineNumber":91,"sourceCode":"    // If -Zbuild-std was passed, download dependencies for the standard library.\n    if let Some(crates) = &gctx.cli_unstable().build_std {\n        let (std_package_set, _, _) = standard_lib::resolve_std(\n            ws,\n            &mut data,\n            &build_config,\n            crates,\n            &build_config.requested_kinds,\n        )?;\n        packages.add_set(std_package_set);\n    }\n\n    packages.get_many(to_download)?;\n    crate::workspace::gc::auto_gc(gctx);\n\n    if ws.gctx().warning_handling()? == WarningHandling::Deny\n        && parse_pass_output.lint_warning_count > 0\n    {\n        anyhow::bail!(\"warnings are denied by `build.warnings` configuration\")\n    }\n\n    Ok((resolve, packages))\n}\n","sourceCodeStart":73,"sourceCodeEnd":96,"githubUrl":"https://github.com/rust-lang/cargo/blob/42eee92bc9aa4449f4e25d84e4ceb1cf8e0f87f9/src/ops/cargo_fetch.rs#L73-L96","documentation":"Thrown by `cargo fetch` when `build.warnings` is set to `\"deny\"` in config (`.cargo/config.toml` or the `CARGO_BUILD_WARNINGS` env / `[build] warnings = \"deny\"`) AND the manifest-parse pass emitted one or more lint warnings (`lint_warning_count > 0`). Cargo treats the deny policy strictly: any warning during manifest parsing aborts the fetch instead of merely printing.","triggerScenarios":"Setting `[build] warnings = \"deny\"` (or `CARGO_BUILD_WARNINGS=deny`) and running `cargo fetch`/`cargo build`/`cargo check` against a manifest that triggers a deprecation or lint warning during the parse pass — e.g. a deprecated manifest key, an unused `[badges]` entry, or a key slated for removal.","commonSituations":"Adopting strict warning policy in CI via `build.warnings = \"deny\"` then upgrading cargo, which newly warns on a previously-silent manifest field. Carrying a legacy `[badges]` table or `edition = \"2015\"` style fields. Switching a repo to deny-warnings after the manifest already has minor issues.","solutions":["Address the specific warning printed just before the bail — remove/replace the offending manifest key or field the parse pass flagged.","Temporarily relax the policy to inspect: `CARGO_BUILD_WARNINGS=warn cargo fetch`, or remove `warnings = \"deny\"` from `[build]` in `.cargo/config.toml`.","Pin the manifest to the schema the current cargo accepts — migrate deprecated keys per the cargo release notes / migration guide.","If the warning is from a dependency's manifest (rare in fetch), update or replace that dependency."],"exampleFix":"# before — .cargo/config.toml\n[build]\nwarnings = \"deny\"\n# manifest has a deprecated key -> fetch aborts\n\n# after — fix the warned field, OR relax\n[build]\nwarnings = \"warn\"","handlingStrategy":"validation","validationCode":"// Before enabling deny mode in CI, run a warn-mode pass to surface manifest lints.\n// `cargo fetch` with CARGO_BUILD_WARNINGS=warn first; only flip to deny when count == 0.\nfn should_deny(warning_count: usize) -> bool { warning_count == 0 }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Introduce `build.warnings = \"deny\"` incrementally — first fix all existing warnings in warn mode.","After every cargo upgrade, run a warn-mode fetch/build and review new manifest lints before re-enabling deny.","Keep manifests free of deprecated keys; follow the cargo edition migration guide.","In CI, run the deny-mode step after a warn-mode diagnostic step so failures are explainable."],"tags":["warnings","config","manifest","lint","fetch"],"backgroundTag":null,"analyzedSha":"42eee92bc9aa4449f4e25d84e4ceb1cf8e0f87f9","analyzedAt":"2026-08-11T17:42:36.556Z","contentChangedAt":"2026-08-11T17:42:36.556Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}