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.


fn foo() {}

This will produce:

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


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.