Skip to content

allow_attributes triggers on variable name #13380

Closed
@Byter09

Description

@Byter09

Summary

When upgrading to 1.81.0 the lint triggered on a variable in our code. I managed to produce a minimal example, unsure if it can be even smaller.

Lint Name

allow_attributes

Reproducer

I tried this code:

#![deny(clippy::allow_attributes)]


pub fn minimal_example() -> Option<u8> {
    let allowed_opt: Option<u8> = None;

    let allowed_raw = allowed_opt?;

    Some(allowed_raw)
}

I saw this happen:

    Checking playground v0.0.1 (/playground)
error: #[allow] attribute found
 --> src/lib.rs:7:23
  |
7 |     let allowed_raw = allowed_opt?;
  |                       ^^^^^^^^^^^^ help: replace it with: `expect`
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#allow_attributes
note: the lint level is defined here
 --> src/lib.rs:1:9
  |
1 | #![deny(clippy::allow_attributes)]
  |         ^^^^^^^^^^^^^^^^^^^^^^^^

error: could not compile `playground` (lib) due to 1 previous error

I expected to see this happen:

    Checking playground v0.0.1 (/playground)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.47s

Version

rustc 1.81.0 (eeb90cda1 2024-09-04)
binary: rustc
commit-hash: eeb90cda1969383f56a2637cbd3037bdf598841c
commit-date: 2024-09-04
host: x86_64-unknown-linux-gnu
release: 1.81.0
LLVM version: 18.1.7

Additional Labels

No response

Metadata

Metadata

Assignees

Labels

C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions