Skip to content

Commit

Permalink
Make lint work on all members of ast::Item_
Browse files Browse the repository at this point in the history
  • Loading branch information
phansch committed Jan 29, 2018
1 parent 8390939 commit aade0d5
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 5 deletions.
2 changes: 1 addition & 1 deletion clippy_lints/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ fn is_relevant_item(tcx: TyCtxt, item: &Item) -> bool {
if let ItemFn(_, _, _, _, _, eid) = item.node {
is_relevant_expr(tcx, tcx.body_tables(eid), &tcx.hir.body(eid).value)
} else {
false
true
}
}

Expand Down
23 changes: 23 additions & 0 deletions tests/ui/empty_line_after_outer_attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,29 @@ fn with_one_newline() { assert!(true) }

fn with_two_newlines() { assert!(true) }


// This should produce a warning
#[crate_type = "lib"]

enum Baz {
One,
Two
}

// This should produce a warning
#[crate_type = "lib"]

struct Foo {
one: isize,
two: isize
}

// This should produce a warning
#[crate_type = "lib"]

mod foo {
}

// This should not produce a warning
#[allow(non_camel_case_types)]
#[allow(missing_docs)]
Expand Down
26 changes: 25 additions & 1 deletion tests/ui/empty_line_after_outer_attribute.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,29 @@ error: Found an empty line after an outer attribute. Perhaps you forgot to add a
25 | | fn with_two_newlines() { assert!(true) }
| |_

error: aborting due to 3 previous errors
error: Found an empty line after an outer attribute. Perhaps you forgot to add a '!' to make it an inner attribute?
--> $DIR/empty_line_after_outer_attribute.rs:29:1
|
29 | / #[crate_type = "lib"]
30 | |
31 | | enum Baz {
| |_

error: Found an empty line after an outer attribute. Perhaps you forgot to add a '!' to make it an inner attribute?
--> $DIR/empty_line_after_outer_attribute.rs:37:1
|
37 | / #[crate_type = "lib"]
38 | |
39 | | struct Foo {
| |_

error: Found an empty line after an outer attribute. Perhaps you forgot to add a '!' to make it an inner attribute?
--> $DIR/empty_line_after_outer_attribute.rs:45:1
|
45 | / #[crate_type = "lib"]
46 | |
47 | | mod foo {
| |_

error: aborting due to 6 previous errors

1 change: 0 additions & 1 deletion tests/ui/inline_fn_without_body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ trait Foo {
#[inline(always)]fn always_inline();

#[inline(never)]

fn never_inline();

#[inline]
Expand Down
3 changes: 1 addition & 2 deletions tests/ui/inline_fn_without_body.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ error: use of `#[inline]` on trait method `never_inline` which has no body
|
13 | #[inline(never)]
| _____-^^^^^^^^^^^^^^^
14 | |
15 | | fn never_inline();
14 | | fn never_inline();
| |____- help: remove

error: aborting due to 3 previous errors
Expand Down

0 comments on commit aade0d5

Please sign in to comment.