Skip to content

Commit f035522

Browse files
committed
Handle rustc_on_unimplemented in duplicated_attributes
1 parent f9f854f commit f035522

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

clippy_lints/src/attrs/duplicated_attributes.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ fn check_duplicated_attr(
3737
}
3838
let Some(ident) = attr.ident() else { return };
3939
let name = ident.name;
40-
if name == sym::doc || name == sym::cfg_attr {
40+
if name == sym::doc || name == sym::cfg_attr || name == sym::rustc_on_unimplemented {
4141
// FIXME: Would be nice to handle `cfg_attr` as well. Only problem is to check that cfg
4242
// conditions are the same.
43+
// `#[rustc_on_unimplemented]` contains duplicated subattributes, that's expected.
4344
return;
4445
}
4546
if let Some(direct_parent) = parent.last()

tests/ui/duplicated_attributes.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,17 @@ fn foo() {}
1515
#[cfg(unix)] //~ ERROR: duplicated attribute
1616
fn bar() {}
1717

18+
// No warning:
19+
#[rustc_on_unimplemented(
20+
on(
21+
_Self = "&str",
22+
label = "`a"
23+
),
24+
on(
25+
_Self = "alloc::string::String",
26+
label = "a"
27+
),
28+
)]
29+
trait Abc {}
30+
1831
fn main() {}

0 commit comments

Comments
 (0)