-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
allow_attributes_without_reason does nothing in Rust 1.81 #13348
Comments
After some more experimentation, I have tracked the problem down - I had this in my rust-version = "1.80.0" This made it fail silently, where by "fail" I mean "do nothing". It's a bit of an odd situation, because although the I wonder if that's the correct behaviour, given that adding In Rust 1.80, this fails: #![forbid(clippy::allow_attributes_without_reason)]
#![deny(clippy::print_stdout)]
#![warn(clippy::allow_attributes)]
#[allow(clippy::print_stdout, reason = "testing")]
fn main() {
println!("Hello, world!");
} Output:
In Rust 1.81, it does not fail:
To me that seems like unexpected behaviour - I would like to see it fail if reasons are present and the MSRV is below 1.81. That would have been a clue. Hopefully my detailing the nature of the problem here will help anyone else who finds themselves in the same situation 🙂 I'll leave this issue open for now, to let you guys decide if this behaviour counts as a bug or not. |
- Bumped the MSRV to 1.81. This properly enables the lint_reasons feature, which was masked: rust-lang/rust-clippy#13348 - Adjusted to pass linting against Rust 1.81.
It seems like it would help to configure one of two potential behaviors:
The former is useful for a project that wants to keep its MSRV at a given level. The latter is useful for a project that wants to document its MSRV but update it whenever needed. |
Marking as nominated for @joshtriplett's suggestion. At RustConf right now and my laptop's keyboard is acting up so I can't write up a separate issue. The current behavior is intentional. If fixing the lint would require raising the MSRV then we don't lint. |
Closing in favor of #13416. |
Summary
I have been using
clippy::allow_attributes_without_reason
for some time, with thelint_reasons
feature enabled under nightly. Recently, theexpect
issue was merged, and I was excited to see that this would all be released as stable in Rust 1.81!However, in trying this in Rust 1.81 (released today), I am unable to get it to work. This seems strange as there should be no feature gate now (obviously features are on nightly not stable), and nightly confirms the feature is stable. So why does it not trigger under the conditions it did before?
Adding the actual reasons is accepted, so it's just the lack of any error or warning from Clippy when they are absent which is puzzling! Perhaps I am doing something wrong?
Note, I have tried the lint via
Cargo.toml
, source code, and-D
on the command line - nothing causes it to trigger. Example below is source code as that's simplest to illustrate.Reproducer
I tried this code:
I expected to see this happen: Clippy to tell me off for allowing without specifying a reason.
Instead, this happened: Clippy was happy, no errors. Note that I was also anticipating something about the use of allow instead of expect, but that didn't trigger either... but I've not previously used that feature.
Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: