Lint reason in Cargo.toml [lints] section

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.

#![warn(clippy::shadow_unrelated, reason = "I'm afraid of shadows")]

fn main() {
    let x = 1 + 2;
    println!("{x}");

    let x = "foo bar";
    println!("{x}");
}
[package]
name = "lint-reason-check"
version = "0.1.0"
edition = "2021"

[dependencies]

[lints.clippy]
shadow_unrelated = { level = "warn", reason = "foo" }

https://doc.rust-lang.org/cargo/reference/manifest.html#the-lints-section

In the above toml file, I can't apply a reason to a lint like I would expect similar to the rust annotation. The only fields supported in that table are level and priority.

I couldn't find an open issue for this. Does anyone know if this is planned to be implemented? Or if there's another way to specify the lint reason in the Cargo.toml.

2 Likes

If you didn't find a tracking issue for this, I would really encourage talking about it on internals.rust-lang.org and even preemptively open an issue

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.