Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should unknown lint tools be a warning? #12496

Closed
ehuss opened this issue Aug 14, 2023 · 4 comments
Closed

Should unknown lint tools be a warning? #12496

ehuss opened this issue Aug 14, 2023 · 4 comments
Labels
A-lints-table Area: [lints] table C-bug Category: bug S-needs-team-input Status: Needs input from team on whether/how to proceed.

Comments

@ehuss
Copy link
Contributor

ehuss commented Aug 14, 2023

Problem

When a new tool is introduced to the lints table, past versions of cargo will generate an error about an unknown tool. This can make it difficult to adopt new tools since it sets a floor on which Rust version is allowed. I'm wondering if it makes sense to treat unknown tools as a warning. Other tables in the manifest usually treat these as warnings (like [package.foo] is a warning).

Steps

Have a manifest with something like:

[package]
name = "foo"
version = "0.1.0"

[lints.new-cool-tool]
new-lint = "warn"

This generates an error:

error: failed to parse manifest at `/Users/eric/Temp/z20/Cargo.toml`

Caused by:
  unsupported `new-cool-tool` in `[lints]`, must be one of rust, clippy, rustdoc

Possible Solution(s)

Generate a warning instead of an error for unknown tools.

Notes

No response

Version

cargo 1.73.0-nightly (d78bbf4bd 2023-08-03)
release: 1.73.0-nightly
commit-hash: d78bbf4bde3c6b95caca7512f537c6f9721426ff
commit-date: 2023-08-03
host: aarch64-apple-darwin
libgit2: 1.6.4 (sys:0.17.2 vendored)
libcurl: 7.88.1 (sys:0.4.65+curl-8.2.1 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 1.1.1u  30 May 2023
os: Mac OS 13.4.1 [64-bit]
@ehuss ehuss added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. A-lints-table Area: [lints] table labels Aug 14, 2023
@epage
Copy link
Contributor

epage commented Aug 14, 2023

Giving this a try with what rustc does:

#!/usr/bin/env -S cargo -Zscript

#![warn(new_cool_tool::new_lint)]

fn main() {}
$ ./cargo-12496.rs
warning: `package.edition` is unspecified, defaulting to `2021`
   Compiling cargo-12496 v0.0.0 (/home/epage/src/personal/dump)
error[E0710]: unknown tool name `new_cool_tool` found in scoped lint: `new_cool_tool::new_lint`
 --> cargo-12496.rs:3:9
  |
3 | #![warn(new_cool_tool::new_lint)]
  |         ^^^^^^^^^^^^^

For more information about this error, try `rustc --explain E0710`.
error: could not compile `cargo-12496` (bin "cargo-12496") due to previous error

@epage
Copy link
Contributor

epage commented Aug 14, 2023

The reason I made this an error, instead of a warning, was to prevent abuse of the [lints] table by arbitrary tools.

@weihanglo
Copy link
Member

If rustc gives an error, maybe cargo would be better follow.

@ehuss ehuss added S-needs-team-input Status: Needs input from team on whether/how to proceed. and removed S-triage Status: This issue is waiting on initial triage. labels Sep 25, 2023
@epage
Copy link
Contributor

epage commented Jul 19, 2024

While there is room for improvement, I believe this specific issue was resolved by #13833.

@epage epage closed this as completed Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints-table Area: [lints] table C-bug Category: bug S-needs-team-input Status: Needs input from team on whether/how to proceed.
Projects
None yet
Development

No branches or pull requests

3 participants