Skip to content

Commit

Permalink
refactor: Warn not Error on unsupported lint tool
Browse files Browse the repository at this point in the history
  • Loading branch information
Muscraft committed Apr 30, 2024
1 parent a1f8e45 commit e4e3278
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
11 changes: 9 additions & 2 deletions src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2231,8 +2231,15 @@ 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 an unrecognized lint tool could lead to future breakage, as `cargo`
reserves all of the `lints` namespace for itself and provides no compatibility
guarantees when encountering unrecognized tools"
);
warnings.push(message);
continue;
}
if tool == "cargo" && !gctx.cli_unstable().cargo_lints {
warn_for_cargo_lint_feature(gctx, warnings);
Expand Down
10 changes: 6 additions & 4 deletions tests/testsuite/lints_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,15 @@ fn fail_on_invalid_tool() {
.build();

foo.cargo("check")
.with_status(101)
.with_stderr(
"\
[..]
[WARNING] [CWD]/Cargo.toml: unrecognized lint tool `lints.super-awesome-linter`
Caused by:
unsupported `super-awesome-linter` in `[lints]`, must be one of cargo, clippy, rust, rustdoc
specifying an unrecognized lint tool could lead to future breakage, as `cargo`
reserves all of the `lints` namespace for itself and provides no compatibility
guarantees when encountering unrecognized tools
[CHECKING] foo v0.0.1 ([CWD])
[FINISHED] [..]
",
)
.run();
Expand Down

0 comments on commit e4e3278

Please sign in to comment.