Skip to content

[mixed_attributes_style] should only lint when mixing the same attribute #12530

Closed
@J-ZhengLi

Description

@J-ZhengLi

Summary

related discussions:

Lint Name

mixed_attributes_style

Reproducer

I tried this code:

#[cfg(test)]
mod tests {
    #![allow(dead_code)]
}

I saw this happen:

warning: item has both inner and outer attributes
 --> src/lib.rs:1:1
  |
1 | / #[cfg(test)]
2 | | mod tests {
3 | |     #![allow(dead_code)]
  | |________________________^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mixed_attributes_style
  = note: `#[warn(clippy::mixed_attributes_style)]` on by default

I expected to see this happen:

no warnings, this is a common syntax, doesn't affect readability.

Version

on playground:

Nightly channel
Build using the Nightly version: 1.79.0-nightly

(2024-03-20 1388d7a069d872bcfe5e)

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    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