Skip to content

allow_attributes_without_reason does nothing in Rust 1.81 #13348

Closed
@danwilliams

Description

@danwilliams

Summary

I have been using clippy::allow_attributes_without_reason for some time, with the lint_reasons feature enabled under nightly. Recently, the expect 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:

#![forbid(clippy::allow_attributes_without_reason)]
#![deny(clippy::print_stdout)]
#![warn(clippy::allow_attributes)]

#[allow(clippy::print_stdout)]
fn main() {
    println!("Hello, world!");
}

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

rustc 1.81.0 (eeb90cda1 2024-09-04)
binary: rustc
commit-hash: eeb90cda1969383f56a2637cbd3037bdf598841c
commit-date: 2024-09-04
host: aarch64-apple-darwin
release: 1.81.0
LLVM version: 18.1.7

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions