Skip to content

Commit

Permalink
Auto merge of #13833 - Muscraft:warn-unknown-tool-lints-table, r=epage
Browse files Browse the repository at this point in the history
fix(lint): Warn not Error on unsupported lint tool

In a recent Cargo Team meeting, it was decided to lessen the error on an unsupported tool in `[lints]` to a warning. This PR implements that change.
  • Loading branch information
bors committed May 1, 2024
2 parents 6087566 + 72f265b commit 1c92c1e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
9 changes: 7 additions & 2 deletions src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2231,8 +2231,13 @@ fn verify_lints(
for (tool, lints) in lints {
let supported = ["cargo", "clippy", "rust", "rustdoc"];
if !supported.contains(&tool.as_str()) {
let supported = supported.join(", ");
anyhow::bail!("unsupported `{tool}` in `[lints]`, must be one of {supported}")
let message = format!(
"unrecognized lint tool `lints.{tool}`, specifying unrecognized tools may break in the future.
supported tools: {}",
supported.join(", "),
);
warnings.push(message);
continue;
}
if tool == "cargo" && !gctx.cli_unstable().cargo_lints {
warn_for_cargo_lint_feature(gctx, warnings);
Expand Down
9 changes: 4 additions & 5 deletions tests/testsuite/lints_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,12 @@ fn fail_on_invalid_tool() {
.build();

foo.cargo("check")
.with_status(101)
.with_stderr(
"\
[..]
Caused by:
unsupported `super-awesome-linter` in `[lints]`, must be one of cargo, clippy, rust, rustdoc
[WARNING] [CWD]/Cargo.toml: unrecognized lint tool `lints.super-awesome-linter`, specifying unrecognized tools may break in the future.
supported tools: cargo, clippy, rust, rustdoc
[CHECKING] foo v0.0.1 ([CWD])
[FINISHED] [..]
",
)
.run();
Expand Down

0 comments on commit 1c92c1e

Please sign in to comment.