From 034c81b76145a0514916f34713671b16f26988df Mon Sep 17 00:00:00 2001 From: Philipp Hansch Date: Mon, 26 Mar 2018 21:57:42 +0200 Subject: [PATCH] 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 #2475 [that_comment]: https://github.com/rust-lang/rust/issues/35900#issuecomment-245978831 --- clippy_lints/src/attrs.rs | 2 +- tests/ui/empty_line_after_outer_attribute.rs | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs index 417ddbe8c12b..38cc40d2e160 100644 --- a/clippy_lints/src/attrs.rs +++ b/clippy_lints/src/attrs.rs @@ -267,7 +267,7 @@ fn check_attrs(cx: &LateContext, span: Span, name: &Name, attrs: &[Attribute]) { return; } if attr.style == AttrStyle::Outer { - if !is_present_in_source(cx, attr.span) { + if attr.tokens.is_empty() || !is_present_in_source(cx, attr.span) { return; } diff --git a/tests/ui/empty_line_after_outer_attribute.rs b/tests/ui/empty_line_after_outer_attribute.rs index beaa98953da7..16eb95abbcbf 100644 --- a/tests/ui/empty_line_after_outer_attribute.rs +++ b/tests/ui/empty_line_after_outer_attribute.rs @@ -67,4 +67,16 @@ pub fn function() -> bool { true } +// This should not produce a warning +#[derive(Clone, Copy)] +pub enum FooFighter { + Bar1, + + Bar2, + + Bar3, + + Bar4 +} + fn main() { }