Skip to content

Commit 034c81b

Browse files
committed
Fix false positive in empty_line_after_outer_attribute
`empty_line_after_outer_attribute` produced a false positive warning when deriving `Copy` and/or `Clone` for an item. It looks like the second point in [this comment][that_comment] is related, as the attribute that causes the false positive has a path of `rustc_copy_clone_marker`. Fixes rust-lang#2475 [that_comment]: rust-lang/rust#35900 (comment)
1 parent eafd090 commit 034c81b

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

clippy_lints/src/attrs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ fn check_attrs(cx: &LateContext, span: Span, name: &Name, attrs: &[Attribute]) {
267267
return;
268268
}
269269
if attr.style == AttrStyle::Outer {
270-
if !is_present_in_source(cx, attr.span) {
270+
if attr.tokens.is_empty() || !is_present_in_source(cx, attr.span) {
271271
return;
272272
}
273273

tests/ui/empty_line_after_outer_attribute.rs

+12
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,16 @@ pub fn function() -> bool {
6767
true
6868
}
6969

70+
// This should not produce a warning
71+
#[derive(Clone, Copy)]
72+
pub enum FooFighter {
73+
Bar1,
74+
75+
Bar2,
76+
77+
Bar3,
78+
79+
Bar4
80+
}
81+
7082
fn main() { }

0 commit comments

Comments
 (0)