DUPLICATE_MACRO_ATTRIBUTES in rustc_lint::builtin - Rust
Description: The `duplicate_macro_attributes` lint detects when a `#[test]`-like built-in macro attribute is duplicated on an item. This lint may trigger on `bench`, `cfg_eval`, `test` and `test_case`.

Skip to main content

## DUPLICATE_MACRO_ATTRIBUTES

# Static DUPLICATE_MACRO_ATTRIBUTES

Source

    pub static DUPLICATE_MACRO_ATTRIBUTES: &'static Lint

Expand description

The `duplicate_macro_attributes` lint detects when a `#[test]`-like built-in macro attribute is duplicated on an item. This lint may trigger on `bench`, `cfg_eval`, `test` and `test_case`.

#### §Example

ⓘ

    #[test]
    #[test]
    fn foo() {}

This will produce:

    warning: duplicated attribute
     --> src/lib.rs:2:1
      |
    2 | #[test]
      | ^^^^^^^
      |
      = note: `#[warn(duplicate_macro_attributes)]` on by default

#### §Explanation

A duplicated attribute may erroneously originate from a copy-paste and the effect of it being duplicated may not be obvious or desirable.

For instance, doubling the `#[test]` attributes registers the test to be run twice with no change to its environment.