Skip to content

Commit

Permalink
Fix false positive in empty_line_after_outer_attribute
Browse files Browse the repository at this point in the history
`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]: rust-lang/rust#35900 (comment)
  • Loading branch information
phansch committed Mar 26, 2018
1 parent eafd090 commit 034c81b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clippy_lints/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
12 changes: 12 additions & 0 deletions tests/ui/empty_line_after_outer_attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() { }

0 comments on commit 034c81b

Please sign in to comment.