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

[lints] table reason #14521

Open
richardscollin opened this issue Sep 9, 2024 · 2 comments
Open

[lints] table reason #14521

richardscollin opened this issue Sep 9, 2024 · 2 comments
Labels
A-lints-table Area: [lints] table A-manifest Area: Cargo.toml issues C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.

Comments

@richardscollin
Copy link

Problem

I was playing around with the new rust 1.81 lint reason feature and I noticed that the reason cannot be set in the Cargo.toml [lints] section like it can in rust code:

#![warn(clippy::shadow_unrelated, reason = "I'm afraid of shadows")]
fn main() {
    let x = 1 + 2;
    println!("{x}");

    let x = "foo bar";
    println!("{x}");
}

Proposed Solution

I would expect that I would be able to set the lint reason in the Cargo.toml like so:

[package]
name = "lint-reason-check"
version = "0.1.0"
edition = "2021"

[dependencies]

[lints.clippy]
shadow_unrelated = { level = "warn", reason = "I'm afraid of shadows" }

I'm unsure what behavior makes sense if the reason is set in both the Cargo.toml file and the rust source file. I'm also not sure if this should be a cargo issue, and rust issue, or a clippy issue.

Notes

No response

@richardscollin richardscollin added C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage. labels Sep 9, 2024
@epage epage added A-lints-table Area: [lints] table A-manifest Area: Cargo.toml issues labels Sep 9, 2024
@epage
Copy link
Contributor

epage commented Sep 9, 2024

Cargo is the appropriate place for this.

The way we currently pass [lints] to rustc, clippy, and rustdoc is insufficient to handle this. That is also true for #12534 and #13565. We need a new way to pass this information to rustc on the command line.

@epage
Copy link
Contributor

epage commented Sep 9, 2024

Speaking of rustc's command-line, there isn't a flag for expect. I wonder if that should also be exposed within this new CLI.

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 A-manifest Area: Cargo.toml issues C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

2 participants